diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 03a2f30..46ae95b 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -43,7 +43,11 @@ ssh "root@$HOST" ' install -m 755 /opt/hnefatafl/app/deploy/hnefatafl-rollup.sh /usr/local/bin/hnefatafl-rollup.sh install -m 755 /opt/hnefatafl/app/deploy/hnefatafl-backup.sh /usr/local/bin/hnefatafl-backup.sh install -m 644 -D /opt/hnefatafl/app/deploy/traffic.py /usr/local/lib/hnefatafl/traffic.py - install -m 644 /opt/hnefatafl/app/deploy/hnefatafl.cron /etc/cron.d/hnefatafl + # On a host the hall shares, its hall-nightly.sh runs the rollup and backup + # of every game and checks in with Sentry once for all; a game on a box of + # its own schedules its own. + if [ -f /etc/cron.d/gamehall ]; then rm -f /etc/cron.d/hnefatafl + else install -m 644 /opt/hnefatafl/app/deploy/hnefatafl.cron /etc/cron.d/hnefatafl; fi mkdir -p /var/log/hnefatafl systemctl daemon-reload systemctl enable --now hnefatafl diff --git a/deploy/hnefatafl-backup.sh b/deploy/hnefatafl-backup.sh index 2e2ab13..1363bab 100755 --- a/deploy/hnefatafl-backup.sh +++ b/deploy/hnefatafl-backup.sh @@ -5,6 +5,8 @@ # Ledgers are append-only JSONL; the game server never needs stopping. # Sentry Crons check-in: /root/.hnefatafl-sentry-cron holds the check-in # URL (absent file = no check-ins). SCHEDULE must match /etc/cron.d/hnefatafl. +# On a host the hall shares, hall-nightly.sh runs this and checks in once +# for every game, so the file is absent and the exit status is the word. set -u SCHEDULE="23 7 * * *" BUCKET="kestrel-wizwar-backups" @@ -27,9 +29,10 @@ checkin() { if [ ! -s /root/.config/rclone/rclone.conf ]; then echo "$(date -Is) skipped: rclone is not configured" >> "$LOG" - exit 0 + exit 1 fi +status=0 { echo "=== $(date -Is) backup start" if rclone sync "$SRC" "spaces:$BUCKET/$PREFIX/current" --exclude 'rollup.jsonl' 2>&1 && @@ -37,6 +40,7 @@ fi checkin ok else checkin error + status=1 fi CUTOFF=$(date -d "90 days ago" +%Y-%m-%d) rclone lsf "spaces:$BUCKET/$PREFIX/snapshots/" --dirs-only 2>/dev/null | \ @@ -49,3 +53,4 @@ fi done echo "=== $(date -Is) backup done" } >> "$LOG" 2>&1 +exit $status diff --git a/deploy/hnefatafl-rollup.sh b/deploy/hnefatafl-rollup.sh index 690853b..e902dfc 100755 --- a/deploy/hnefatafl-rollup.sh +++ b/deploy/hnefatafl-rollup.sh @@ -8,7 +8,9 @@ # Cron: /etc/cron.d/hnefatafl, installed by deploy.sh; SCHEDULE below # must match it, because the Sentry monitor is told the same shape. # Sentry Crons check-in: /root/.hnefatafl-sentry-cron-rollup holds the -# check-in URL (absent = no check-ins). +# check-in URL (absent = no check-ins). On a host the hall shares, +# hall-nightly.sh runs this and checks in once for every game, so the +# file is absent and the exit status is the word. set -u OUT="/var/lib/hnefatafl/rollup.jsonl" LOG="/var/log/hnefatafl/rollup.log" @@ -78,4 +80,4 @@ with open(out + ".tmp", "w") as fh: os.replace(out + ".tmp", out) print("%s rolled: %d people, %d requests, %d rooms" % (day, len(t["addresses"]), t["human"], created)) PY -then checkin ok; else checkin error; fi +then checkin ok; else checkin error; exit 1; fi