From 567590464e0c6246125fcb4dfedfd680628128c4 Mon Sep 17 00:00:00 2001 From: Eric Wagoner Date: Mon, 5 Oct 2026 21:55:28 -0400 Subject: [PATCH] hall-announce --clear leaves an empty notice rather than no file, so no page's check is a failed request Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG --- gamehall/ops/hall-announce.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gamehall/ops/hall-announce.sh b/gamehall/ops/hall-announce.sh index 87644ab..d54810f 100644 --- a/gamehall/ops/hall-announce.sh +++ b/gamehall/ops/hall-announce.sh @@ -10,9 +10,11 @@ set -euo pipefail FILE=/var/lib/hall/announcement.json +# No notice is an empty one, {}, never a missing file: a page's check for a missing file +# is a failed request, and the browser reports it in every visitor's console. case "${1:-}" in - --clear) rm -f "$FILE"; echo "cleared."; exit 0 ;; - --show) cat "$FILE" 2>/dev/null || echo "no announcement."; exit 0 ;; + --clear) mkdir -p "$(dirname "$FILE")"; echo '{}' > "$FILE.tmp"; chmod 644 "$FILE.tmp"; mv "$FILE.tmp" "$FILE"; echo "cleared."; exit 0 ;; + --show) if grep -q '"text"' "$FILE" 2>/dev/null; then cat "$FILE"; else echo "no announcement."; fi; exit 0 ;; ''|-*) sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;; esac