pct exec runs as root while /opt/linkvault is owned by the linkvault user, so newer git versions refuse to operate on it. Mark the directory as safe before running git pull. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.3 KiB
Bash
Executable File
48 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
#
|
||
# LinkVault – Update-Script für einen bestehenden Proxmox-LXC-Container
|
||
#
|
||
# Muss als root auf dem Proxmox-VE-Host ausgeführt werden. Zieht den
|
||
# neuesten Stand aus Git, aktualisiert die Python-Abhängigkeiten und
|
||
# startet den systemd-Service neu.
|
||
#
|
||
# Verwendung (auf dem Proxmox-Host):
|
||
# CTID=113 bash update-linkvault.sh
|
||
#
|
||
# Bei privatem Repo zusätzlich das Gitea Access Token setzen:
|
||
# CTID=113 GIT_TOKEN=<token> bash update-linkvault.sh
|
||
#
|
||
set -euo pipefail
|
||
|
||
CTID="${CTID:-}"
|
||
GIT_TOKEN="${GIT_TOKEN:-}"
|
||
|
||
if ! command -v pct &>/dev/null; then
|
||
echo "Fehler: 'pct' nicht gefunden – dieses Script muss auf einem Proxmox-VE-Host laufen." >&2
|
||
exit 1
|
||
fi
|
||
|
||
if [ -z "$CTID" ]; then
|
||
echo "Fehler: CTID muss gesetzt sein, z.B. 'CTID=113 bash update-linkvault.sh'." >&2
|
||
exit 1
|
||
fi
|
||
|
||
echo "==> Aktualisiere LinkVault in Container $CTID..."
|
||
pct exec "$CTID" -- bash -c "
|
||
set -euo pipefail
|
||
git config --global --add safe.directory /opt/linkvault
|
||
cd /opt/linkvault
|
||
|
||
if [ -n '${GIT_TOKEN}' ]; then
|
||
git -c http.extraHeader=\"Authorization: token ${GIT_TOKEN}\" pull --ff-only
|
||
else
|
||
git pull --ff-only
|
||
fi
|
||
|
||
.venv/bin/pip install -q -r requirements.txt
|
||
systemctl restart linkvault
|
||
"
|
||
|
||
echo "==> Fertig. Status:"
|
||
pct exec "$CTID" -- systemctl --no-pager status linkvault
|