also use .env
This commit is contained in:
@@ -76,8 +76,8 @@ also needs **Project: Read** there.
|
|||||||
|
|
||||||
## Every 30 minutes, on a server
|
## Every 30 minutes, on a server
|
||||||
|
|
||||||
Copy the repo to the server, create `ctf_status.env` there (it is gitignored, so it
|
Copy the repo to the server, create `ctf_status.env` or `.env` there (both are gitignored, so they
|
||||||
does not travel with the code), then:
|
do not travel with the code), then:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./install-timer.sh
|
./install-timer.sh
|
||||||
|
|||||||
+14
-8
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# Install the 30-minute HedgeDoc refresh as systemd *user* units.
|
# Install the 30-minute HedgeDoc refresh as systemd *user* units.
|
||||||
# Run it as the user that owns ctf_status.env, on the machine that should do the
|
# 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.
|
# polling. Re-running it is safe; it just overwrites the units.
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
@@ -8,13 +8,19 @@ dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
|
|||||||
units="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
units="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||||
|
|
||||||
[ -x "$dir/ctf_status.py" ] || { echo "no executable ctf_status.py in $dir" >&2; exit 1; }
|
[ -x "$dir/ctf_status.py" ] || { echo "no executable ctf_status.py in $dir" >&2; exit 1; }
|
||||||
[ -f "$dir/ctf_status.env" ] || {
|
# ctf_status.py reads ctf_status.env and .env; either (or both) will do
|
||||||
echo "no $dir/ctf_status.env — copy ctf_status.env.example to it first" >&2; exit 1; }
|
set --
|
||||||
grep -q '^HEDGEDOC_NOTE=..*' "$dir/ctf_status.env" || {
|
for f in "$dir/ctf_status.env" "$dir/.env"; do
|
||||||
echo "set HEDGEDOC_NOTE=<note url> in $dir/ctf_status.env first" >&2; exit 1; }
|
if [ -f "$f" ]; then set -- "$@" "$f"; fi
|
||||||
grep -q '^CHALLS_REPO_URL=..*' "$dir/ctf_status.env" || {
|
done
|
||||||
echo "set CHALLS_REPO_URL=<deployment repo url> in $dir/ctf_status.env first" >&2; exit 1; }
|
[ $# -gt 0 ] || {
|
||||||
chmod 600 "$dir/ctf_status.env"
|
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
|
||||||
|
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"
|
mkdir -p "$units"
|
||||||
for u in ctf-status.service ctf-status.timer; do
|
for u in ctf-status.service ctf-status.timer; do
|
||||||
|
|||||||
Reference in New Issue
Block a user