Files
wibosim/scripts/install-autoupdate.sh
T
db9979andClaude Opus 5.5 9f829954d1 Betrieb: Update-Fenster, Sicherung und Zurücksetzen vor jedem Update, „Was ist neu“ gebündelt, Test-Instanz
- auto-update.sh holt Images weiter alle 5 Minuten, spielt aber erst ein, wenn das Spiel es erlaubt
  (POST /api/ops/update-ok per docker exec): Update-Fenster (Standard 03:00–05:00), Börse zu ohne Battle,
  sofort, dringende Version (urgent: true im Changelog), Admin-Knopf „Jetzt einspielen“; Rückfall: einspielen
- Hinweis an Spieler einige Minuten vorher (updSoon), Sicherung per VACUUM INTO unmittelbar vor dem Neustart
  mit eigener Rotation, Gesundheitsprüfung über /healthz, automatisch zurück auf das vorige Image und notfalls
  Spielstand zurückspielen, Ausfall-Meldung an die Spielleitung
- Admin: Gruppe „Update-Fenster“ und Karte „Update“ (wartende Version, Plan, Verlauf, Zurücksetzen mit Bestätigung);
  rollback.sh --vorher [--mit-daten] mit Rückfrage; gemeinsame Bausteine in scripts/lib-update.sh
- „Was ist neu“: gebündelt seit der zuletzt gesehenen Version des Kontos, gruppiert, höchstens 8 Punkte sichtbar,
  ohne Admin-Zeilen, nicht für neue Spieler
- Test-Instanz (docker compose --profile test): Kopie der neuesten Live-Sicherung, Mails/Push/Taby aus, TESTINSTANZ im Kopf
- Tests: updgate, whatsnew/testinst, Skripte mit Attrappen; docs/BETRIEB.md mit Einrichtung, Umstellung, Was tun wenn

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUhQVoPUusUzxgxLWkK
2026-12-05 10:48:24 +00:00

59 lines
2.2 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
# Richtet das automatische Update ein (systemd-Timer, sonst cron): alle 5 Minuten scripts/auto-update.sh.
# scripts/install-autoupdate.sh → einschalten
# scripts/install-autoupdate.sh --remove → ausschalten
set -euo pipefail
cd "$(dirname "$0")/.."
DIR=$(pwd)
USER_NAME=$(id -un)
chmod +x scripts/auto-update.sh scripts/rollback.sh
if [ "${1:-}" = "--remove" ]; then
if command -v systemctl >/dev/null && [ -f /etc/systemd/system/wibosim-update.timer ]; then
sudo systemctl disable --now wibosim-update.timer
sudo rm -f /etc/systemd/system/wibosim-update.timer /etc/systemd/system/wibosim-update.service
sudo systemctl daemon-reload
fi
(crontab -l 2>/dev/null | grep -v 'scripts/auto-update.sh') | crontab - 2>/dev/null || true
echo "Automatisches Update ausgeschaltet."
exit 0
fi
if command -v systemctl >/dev/null && [ -d /run/systemd/system ]; then
sudo tee /etc/systemd/system/wibosim-update.service >/dev/null <<UNIT
[Unit]
Description=WiBoSim: automatisches Update
After=network-online.target docker.service
Wants=network-online.target
[Service]
Type=oneshot
User=$USER_NAME
WorkingDirectory=$DIR
ExecStart=$DIR/scripts/auto-update.sh
UNIT
sudo tee /etc/systemd/system/wibosim-update.timer >/dev/null <<UNIT
[Unit]
Description=WiBoSim: alle 5 Minuten nach Updates sehen
[Timer]
OnBootSec=3min
OnUnitActiveSec=5min
RandomizedDelaySec=30
[Install]
WantedBy=timers.target
UNIT
sudo systemctl daemon-reload
sudo systemctl enable --now wibosim-update.timer
echo "✅ Automatisches Update eingeschaltet (systemd-Timer, alle 5 Minuten)."
echo " Status: systemctl list-timers wibosim-update.timer"
else
(crontab -l 2>/dev/null | grep -v 'scripts/auto-update.sh'; echo "*/5 * * * * $DIR/scripts/auto-update.sh >/dev/null 2>&1") | crontab -
echo "✅ Automatisches Update eingeschaltet (cron, alle 5 Minuten)."
fi
echo " Protokoll: $DIR/autoupdate.log"
echo " Eingespielt wird im Update-Fenster (Standard 03:00–05:00) – einstellbar im Admin-Menü:"
echo " Einstellungen → Datenpflege & Betrieb → Update-Fenster (dort auch „Jetzt einspielen“ und „Zurücksetzen“)."
echo " Ausschalten: scripts/install-autoupdate.sh --remove"