Skip to content

Commit 04e33d3

Browse files
turegjorupclaude
andcommitted
Fix install-secrets.sh sentinel check for non-task invocation
PR #29's e2e workflow surfaced this: when invoked directly (not via `task install`), the script silently no-ops and the stack comes up with mariadb running on the literal CHANGE_ME password while DATABASE_URL has the would-be-random hex. Doctrine: access denied, exit code 1045. Root cause: the sentinel check reads `$MARIADB_PASSWORD` from the env, which is populated by Taskfile's `dotenv:` directive — but only when the script runs as part of a `task` invocation. Direct invocation (CI workflow, operator running from a fresh shell) leaves both $MARIADB_PASSWORD and $MARIADB_ROOT_PASSWORD empty. The condition "if NEITHER is CHANGE_ME, skip" then matches because both are "" — not "CHANGE_ME" — and the script exits 0 without doing anything. Fix: source .env.mariadb at the top of the script. Idempotent when the env is already populated; load-bearing for direct invocation. Same pattern env-init.sh uses for .env. Verified: `env -i ./install-secrets.sh` (empty env) now correctly detects the CHANGE_ME sentinel, generates random passwords, and syncs DATABASE_URL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 64f2783 commit 04e33d3

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/install-secrets.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ if [ ! -f .env.mariadb ] || [ ! -f .env.symfony ]; then
1818
exit 1
1919
fi
2020

21-
# Sentinel detection via env vars (loaded by Taskfile's `dotenv:` directive).
22-
# If neither password is the CHANGE_ME placeholder, there's nothing to do.
21+
# Source .env.mariadb so $MARIADB_PASSWORD etc. are set whether the
22+
# script runs via `task install` (Taskfile's `dotenv:` already loaded it)
23+
# or stand-alone (CI workflow, manual invocation). Without this, an empty
24+
# env defeats the sentinel check below — both `${VAR:-}` evaluate to
25+
# empty (≠ "CHANGE_ME"), so the script silently exits 0 and mariadb
26+
# starts with the literal CHANGE_ME password from the file.
27+
set -a
28+
# shellcheck disable=SC1091
29+
. ./.env.mariadb
30+
set +a
31+
32+
# Sentinel detection. If neither password is the CHANGE_ME placeholder,
33+
# there's nothing to do.
2334
if [ "${MARIADB_PASSWORD:-}" != "CHANGE_ME" ] && [ "${MARIADB_ROOT_PASSWORD:-}" != "CHANGE_ME" ]; then
2435
exit 0
2536
fi

0 commit comments

Comments
 (0)