Generate missing secrets in --only mode for existing installs

SETTINGS_DB_PASS and SETTINGS_SECRET won't be in the credentials file
on stacks installed before settings was added. Generate and append them
automatically so --only settings works without a full reinstall.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-01 19:13:19 +00:00
parent 76f5276f4b
commit 22a99f804e

View file

@ -962,6 +962,18 @@ if [[ "${1:-}" == "--only" ]]; then
key="${line%%=*}"; value="${line#*=}" key="${line%%=*}"; value="${line#*=}"
export "$key"="$value" export "$key"="$value"
done < "$CREDS_FILE" done < "$CREDS_FILE"
# Generate and append any secrets that didn't exist when the stack was first installed
_append_secret() {
local var=$1 val=$2
export "$var"="$val"
echo "${var}=${val}" >> "$CREDS_FILE"
msg_ok "Generated missing secret: ${var}"
}
[[ -z "${SETTINGS_DB_PASS:-}" ]] && _append_secret SETTINGS_DB_PASS \
"$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)"
[[ -z "${SETTINGS_SECRET:-}" ]] && _append_secret SETTINGS_SECRET \
"$(openssl rand -hex 32)"
USE_FORGEJO=true USE_FORGEJO=true
[[ -f /root/.ssh/hotel-manage_deploy.pub ]] \ [[ -f /root/.ssh/hotel-manage_deploy.pub ]] \
&& MGMT_PUBKEY=$(cat /root/.ssh/hotel-manage_deploy.pub) || MGMT_PUBKEY="" && MGMT_PUBKEY=$(cat /root/.ssh/hotel-manage_deploy.pub) || MGMT_PUBKEY=""