Files
wibosim/scripts/deploy-pi.sh
T
db9979andClaude Opus 5.5 939fe5def5 Version 0.9.0, Änderungsprotokoll und automatisches Update
- Versionsnummer, Build (Git-Commit) und Bauzeit unter /api/version, in /api/info und hello
- Änderungsprotokoll für Spieler unter /api/changelog (Test prüft Übereinstimmung mit package.json)
- Server meldet Neustarts an die Clients; statische Dateien ohne langes Zwischenspeichern
- Admin: Hinweis, wenn auf GitHub eine neuere Version liegt
- Pi: scripts/install-autoupdate.sh (systemd-Timer oder cron) mit Zeitfenster, Gesundheitscheck und automatischem Zurückrollen
- CI übergibt Bauzeit ans Image; Doku zu Updates, Versionen und KI-Auswertung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUhQVoPUusUzxgxLWkK
2026-12-03 19:56:03 +00:00

60 lines
2.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Deployment auf dem Raspberry Pi (192.168.178.21).
# Einmalig auf dem Pi ausführen: curl -fsSL https://raw.githubusercontent.com/db9979/wibosim/main/scripts/deploy-pi.sh | bash
# Danach für Updates einfach erneut ausführen (oder: cd ~/wibosim && docker compose pull && docker compose up -d).
# Mit automatischem Update (alle 5 Minuten neue Version von GitHub holen): AUTOUPDATE=1 scripts/deploy-pi.sh
# (oder später: scripts/install-autoupdate.sh)
set -euo pipefail
REPO="${REPO:-https://github.com/db9979/wibosim.git}"
DIR="${DIR:-$HOME/wibosim}"
if ! command -v docker >/dev/null; then
echo ">> Docker wird installiert …"
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker "$USER"
echo ">> Docker installiert. Bitte einmal ab- und wieder anmelden und das Skript erneut starten."
exit 0
fi
if [ -d "$DIR/.git" ]; then
echo ">> Aktualisiere $DIR"; git -C "$DIR" pull --ff-only
else
echo ">> Klone nach $DIR"; git clone "$REPO" "$DIR"
fi
cd "$DIR"
[ -f .env ] || cp .env.example .env
# Vor dem Update: Version merken (für scripts/rollback.sh)
PREV=$(docker inspect --format '{{index .Config.Labels "org.opencontainers.image.version"}}' wibosim 2>/dev/null || true)
[ -n "$PREV" ] && echo "$PREV" > .last-version
echo ">> Hole fertiges Image (amd64/arm64) …"
if docker compose pull wibosim 2>/dev/null; then
docker compose up -d
else
echo ">> Kein fertiges Image erreichbar – baue lokal (dauert auf dem Pi einige Minuten) …"
docker compose up -d --build
fi
docker image prune -f >/dev/null
echo ">> Warte auf den Gesundheitscheck …"
for i in $(seq 1 30); do
if curl -fsS http://127.0.0.1:8086/api/health >/dev/null 2>&1; then OK=1; break; fi
sleep 2
done
IP=$(hostname -I | awk '{print $1}')
echo
if [ "${OK:-0}" = 1 ]; then
echo "✅ WiBoSim läuft: http://${IP}:8086"
else
echo "⚠️ Gesundheitscheck noch nicht erfolgreich – Logs prüfen: docker compose logs --tail 100"
fi
echo " Admin-Menü: http://${IP}:8086/admin"
echo " Admin einrichten: Einrichtungscode steht im Log → docker compose logs wibosim | grep Einrichtungscode"
echo " Zurück auf die vorige Version: scripts/rollback.sh"
if [ "${AUTOUPDATE:-0}" = 1 ]; then
scripts/install-autoupdate.sh
elif ! systemctl is-enabled wibosim-update.timer >/dev/null 2>&1 && ! crontab -l 2>/dev/null | grep -q auto-update.sh; then
echo " Automatische Updates einschalten: scripts/install-autoupdate.sh"
fi