diff --git a/infra/board/.env.example b/infra/board/.env.example index dd655e3..1e11dd1 100644 --- a/infra/board/.env.example +++ b/infra/board/.env.example @@ -14,9 +14,18 @@ BOARD_SECRET_KEY= # database, and ignored afterwards. BOARD_OWNER=pablo -# Optional. A site-admin token lets admins create Gitea accounts from inside -# the members area. Without it, everything works except account creation, and -# admins add people who already have a Gitea login. +# Optional, and by now almost certainly unnecessary. It could create accounts on +# the git server for new members, back when a member needed one to sign in. They +# do not: a password lives in this app's own database. Nothing in the members +# area calls it any more. +# +# It CANNOT publish. Gitea's token scopes are per category and `admin` does not +# contain `repository`, so a site-admin token gets a 403 from the contents API — +# leaving this filled in and CONTENT_TOKEN empty is how the editor ends up unable +# to commit a single post while looking configured. +# +# Fill in CONTENT_TOKEN below, then revoke this one: it can create and modify +# every account on the instance, and anything that can read this file can use it. GITEA_ADMIN_TOKEN= # What the content editor commits with. Members sign in here, on diff --git a/scripts/deploy-board.sh b/scripts/deploy-board.sh index 1226d97..5b66f0e 100755 --- a/scripts/deploy-board.sh +++ b/scripts/deploy-board.sh @@ -45,10 +45,22 @@ fi missing="$(comm -23 \ <(grep -oE '^[A-Z][A-Z0-9_]*=' "$TARGET/.env.example" | sort -u) \ <(grep -oE '^[A-Z][A-Z0-9_]*=' "$TARGET/.env" | sort -u) || true)" +note_for() { + case "${1%=}" in + CONTENT_TOKEN) echo "el editor no puede publicar nada en el sitio" ;; + GITEA_ADMIN_TOKEN) echo "sólo para cuentas del servidor de git; NO publica" ;; + MAIL_HOST|MAIL_PASSWORD) echo "no se envían invitaciones ni recuperaciones" ;; + BOARD_SECRET_KEY) echo "LA APP NO ARRANCA" ;; + *) echo "" ;; + esac +} + if [ -n "$missing" ]; then echo echo "!! These settings exist in .env.example but not in your .env:" - echo "$missing" | sed 's/^/ /' + while read -r name; do + printf ' %-20s %s\n' "$name" "$(note_for "$name")" + done <<< "$missing" echo " Add them to $TARGET/.env and run this again if the feature needs them." echo fi @@ -62,13 +74,7 @@ if [ -n "$blank" ]; then echo echo "!! These are set to nothing in your .env, so their feature is off:" while read -r name; do - case "$name" in - GITEA_ADMIN_TOKEN) note="no se pueden crear cuentas ni cambiar contraseñas" ;; - MAIL_HOST|MAIL_PASSWORD) note="no se envían invitaciones ni recuperaciones" ;; - BOARD_SECRET_KEY) note="LA APP NO ARRANCA" ;; - *) note="" ;; - esac - printf ' %-20s %s\n' "$name" "$note" + printf ' %-20s %s\n' "$name" "$(note_for "$name")" done <<< "$blank" echo fi @@ -85,6 +91,27 @@ if [ -z "${BOARD_SKIP_BACKUP:-}" ] && [ -f "${BOARD_DB:-$TARGET/data/board.db}" bash "$REPO/scripts/backup-board.sh" fi +# The mirror image of the check above: settings your .env holds that +# .env.example no longer documents. Those are what a feature looks like after it +# is removed — the OAuth client id and secret outlived the login they belonged +# to by two phases, sitting in a file as live credentials for a flow nothing +# calls. A commented-out line in the example counts as undocumented, which is +# how a setting is retired: comment it there, and this names it here. +# +# Named, never touched: this script has never written to .env and does not start +# now. Deleting a line is a decision, and the file may hold something deliberate +# that the repository does not know about. +stale="$(comm -13 \ + <(grep -oE '^[A-Z][A-Z0-9_]*=' "$TARGET/.env.example" | sort -u) \ + <(grep -oE '^[A-Z][A-Z0-9_]*=' "$TARGET/.env" | sort -u) || true)" +if [ -n "$stale" ]; then + echo + echo "!! Your .env has settings the repository no longer documents:" + echo "$stale" | sed 's/^/ /' + echo " Nothing reads them. If one holds a secret, revoke it and delete the line." + echo +fi + echo "==> Restarting" cd "$TARGET" docker compose up -d --force-recreate