mirror of
https://github.com/db9979/wibosim.git
synced 2026-12-06 05:24:08 +01:00
- 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
58 lines
2.0 KiB
Bash
Executable File
58 lines
2.0 KiB
Bash
Executable File
#!/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
|
|
|
|
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 " Nur nachts aktualisieren: in .env AUTOUPDATE_WINDOW=03-05 eintragen."
|
|
echo " Ausschalten: scripts/install-autoupdate.sh --remove"
|