proxmox-update.sh: Update-Script fur LXC-Container (git pull + restart)
This commit is contained in:
62
proxmox-update.sh
Executable file
62
proxmox-update.sh
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Update-Script: 3D-Druck Kostenkalkulation im Proxmox LXC Container
|
||||||
|
# Im Container ausfuehren (pct enter <CT_ID> oder SSH).
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./proxmox-update.sh # interaktiv, fragt CT_ID
|
||||||
|
# ./proxmox-update.sh 201 # CT direkt angeben
|
||||||
|
#
|
||||||
|
# Von aussen (Proxmox-Host):
|
||||||
|
# pct enter 201 -- ./proxmox-update.sh 201
|
||||||
|
# pct push 201 proxmox-update.sh /opt/3ddruck-kalkulation/proxmox-update.sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CT_ID="${1:-}"
|
||||||
|
APP_DIR="/opt/3ddruck-kalkulation"
|
||||||
|
SERVICE="3ddruck-kalkulation"
|
||||||
|
|
||||||
|
# Pruefen ob wir im Container sind oder den CT_ID brauchen
|
||||||
|
if [ -z "$CT_ID" ]; then
|
||||||
|
if [ -d "$APP_DIR" ] && [ -f "/etc/systemd/system/$SERVICE.service" ]; then
|
||||||
|
echo "=== Update $APP_DIR ... ==="
|
||||||
|
else
|
||||||
|
echo "Usage: $0 <CT_ID>"
|
||||||
|
echo " oder im Container ausfuehren ohne Argument"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "=== Update via pct exec CT $CT_ID ... ==="
|
||||||
|
SCRIPT=$(realpath "$0")
|
||||||
|
pct push "$CT_ID" "$SCRIPT" "/tmp/proxmox-update.sh"
|
||||||
|
pct exec "$CT_ID" -- bash /tmp/proxmox-update.sh
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Im Container
|
||||||
|
if [ ! -d "$APP_DIR" ]; then
|
||||||
|
echo "Fehler: $APP_DIR existiert nicht"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
|
echo "=== Alte Abhaengigkeiten sichern ==="
|
||||||
|
OLD_DEPS=$(.venv/bin/pip freeze 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
echo "=== Pull von Git ==="
|
||||||
|
git pull
|
||||||
|
|
||||||
|
echo "=== Python-Dependencies aktualisieren ==="
|
||||||
|
.venv/bin/pip install --upgrade flask fpdf2 pyyaml 2>/dev/null || \
|
||||||
|
.venv/bin/pip install flask fpdf2 pyyaml
|
||||||
|
|
||||||
|
echo "=== Service neustarten ==="
|
||||||
|
systemctl restart "$SERVICE"
|
||||||
|
|
||||||
|
echo "=== Status ==="
|
||||||
|
sleep 2
|
||||||
|
systemctl status "$SERVICE" --no-pager | head -10
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Fertig! ==="
|
||||||
Reference in New Issue
Block a user