ctf_status.py is now just the command line; the work lives in tracker/. The rules that decide whether a challenge is believed are in tracker/checks.py, one function per rule, listed in README_CHECKS and REPO_CHECKS. Output is unchanged. Read the config from .env only (ctf_status.env.example -> .env.example), let single_run_lock() hold its own lock files, and rewrite the README as a short overview of what the repo does and how to run it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# 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 .env, on the machine that should do the polling.
|
|
# Re-running it is safe; it just overwrites the units.
|
|
set -eu
|
|
|
|
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
|
|
units="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
|
env="$dir/.env"
|
|
|
|
[ -x "$dir/ctf_status.py" ] || { echo "no executable ctf_status.py in $dir" >&2; exit 1; }
|
|
[ -f "$env" ] || { echo "no .env in $dir — copy .env.example to .env first" >&2; exit 1; }
|
|
# the timers run --update and --challs, which need these two
|
|
for key in HEDGEDOC_NOTE CHALLS_REPO_URL; do
|
|
grep -qi "^$key=..*" "$env" || { echo "set $key=... in $env first" >&2; exit 1; }
|
|
done
|
|
chmod 600 "$env"
|
|
|
|
mkdir -p "$units"
|
|
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 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
|
|
loginctl enable-linger "$(id -un)" 2>/dev/null \
|
|
|| echo "could not enable linger; run: sudo loginctl enable-linger $(id -un)" >&2
|
|
fi
|
|
|
|
echo
|
|
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
|