Fix ROMM_AUTH_SECRET_KEY auto-generation under nounset

The init script runs with `set -o nounset`, so testing `${ROMM_AUTH_SECRET_KEY}`
aborted with "unbound variable" before reaching the generation branch, leaving
the container in a restart loop. This only triggered when the variable was
omitted entirely; shipping it with an empty value took the working path.

Use `${ROMM_AUTH_SECRET_KEY-}` so the unset case is testable, and warn instead
of info since a generated key changes on every restart.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georges-Antoine Assi
2026-07-27 08:07:50 -04:00
parent ce49cd0c55
commit 98651ecbf8
5 changed files with 16 additions and 16 deletions

View File

@@ -332,9 +332,9 @@ if ! printenv | grep -q '^OTEL_'; then
fi
# Set ROMM_AUTH_SECRET_KEY if not already set
if [[ -z ${ROMM_AUTH_SECRET_KEY} ]]; then
if [[ -z ${ROMM_AUTH_SECRET_KEY-} ]]; then
ROMM_AUTH_SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")
info_log "ROMM_AUTH_SECRET_KEY not set, generating random secret key"
warn_log "ROMM_AUTH_SECRET_KEY not set, generating a random secret key. It changes on every restart, invalidating API bearer tokens and pending invite/password-reset links. Set it explicitly to keep those valid, and always set it when running more than one replica."
export ROMM_AUTH_SECRET_KEY
fi