Commit challs.txt once a day at 04:00, separate from the HedgeDoc refresh

The 30-minute timer now only updates the HedgeDoc note; a new
ctf-challs.timer runs --challs daily at 04:00. Locks are per target so
the two runs can overlap without one skipping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 17:47:57 +02:00
co-authored by Claude Opus 5.5
parent cb5184a55d
commit ec2f444ef3
6 changed files with 63 additions and 28 deletions
+8 -7
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env sh
# Install the 30-minute HedgeDoc refresh as systemd *user* units.
# Install the 30-minute HedgeDoc refresh and the daily 04:00 challs.txt commit
# as systemd *user* units.
# Run it as the user that owns ctf_status.env / .env, on the machine that should do the
# polling. Re-running it is safe; it just overwrites the units.
set -eu
@@ -16,20 +17,20 @@ done
[ $# -gt 0 ] || {
echo "no ctf_status.env or .env in $dir — copy ctf_status.env.example to one first" >&2
exit 1; }
# the timer runs --update --challs, which need these two
# the timers run --update and --challs, which need these two
for key in HEDGEDOC_NOTE CHALLS_REPO_URL; do
grep -qi "^$key=..*" "$@" || { echo "set $key=... in $* first" >&2; exit 1; }
done
chmod 600 "$@"
mkdir -p "$units"
for u in ctf-status.service ctf-status.timer; do
for u in ctf-status.service ctf-status.timer ctf-challs.service ctf-challs.timer; do
sed "s|__DIR__|$dir|g" "$dir/$u" > "$units/$u"
echo "installed $units/$u"
done
systemctl --user daemon-reload
systemctl --user enable --now ctf-status.timer
systemctl --user enable --now ctf-status.timer ctf-challs.timer
# without lingering, user units are torn down as soon as you log out
if ! loginctl show-user "$(id -un)" -p Linger --value 2>/dev/null | grep -qx yes; then
@@ -38,6 +39,6 @@ if ! loginctl show-user "$(id -un)" -p Linger --value 2>/dev/null | grep -qx yes
fi
echo
echo "one run now, to prove it works:"
systemctl --user start ctf-status.service && echo " ok"
systemctl --user list-timers ctf-status.timer --no-pager
echo "one run of each now, to prove they work:"
systemctl --user start ctf-status.service ctf-challs.service && echo " ok"
systemctl --user list-timers ctf-status.timer ctf-challs.timer --no-pager