Fix --only mode credential parsing for values with spaces
Replace source+grep with a safe line-by-line reader so SITE_NAME and ADMIN_PASS with spaces do not get interpreted as shell commands. Also quote SITE_NAME and ADMIN_PASS in the written credentials file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
259a1457aa
commit
285d6609b1
1 changed files with 8 additions and 3 deletions
|
|
@ -272,10 +272,10 @@ gen_secrets() {
|
||||||
# Hotel Manage credentials — generated $(date '+%Y-%m-%d %H:%M')
|
# Hotel Manage credentials — generated $(date '+%Y-%m-%d %H:%M')
|
||||||
# !! KEEP THIS FILE SAFE — store a copy offsite !!
|
# !! KEEP THIS FILE SAFE — store a copy offsite !!
|
||||||
|
|
||||||
SITE_NAME=${SITE_NAME}
|
SITE_NAME="${SITE_NAME}"
|
||||||
DOMAIN=${DOMAIN}
|
DOMAIN=${DOMAIN}
|
||||||
ADMIN_EMAIL=${ADMIN_EMAIL}
|
ADMIN_EMAIL=${ADMIN_EMAIL}
|
||||||
ADMIN_PASS=${ADMIN_PASS}
|
ADMIN_PASS="${ADMIN_PASS}"
|
||||||
OFFICE_IP_CHECK=${OFFICE_IP}
|
OFFICE_IP_CHECK=${OFFICE_IP}
|
||||||
|
|
||||||
PG_SUPERPASS=${PG_SUPERPASS}
|
PG_SUPERPASS=${PG_SUPERPASS}
|
||||||
|
|
@ -956,7 +956,12 @@ if [[ "${1:-}" == "--only" ]]; then
|
||||||
grep -qw "$ONLY" <<< "$VALID" || msg_error "Unknown service '${ONLY}'. Valid: ${VALID}"
|
grep -qw "$ONLY" <<< "$VALID" || msg_error "Unknown service '${ONLY}'. Valid: ${VALID}"
|
||||||
CREDS_FILE=/root/hotel-manage-credentials.txt
|
CREDS_FILE=/root/hotel-manage-credentials.txt
|
||||||
[[ -f "$CREDS_FILE" ]] || msg_error "No credentials file at ${CREDS_FILE} — run the full installer first"
|
[[ -f "$CREDS_FILE" ]] || msg_error "No credentials file at ${CREDS_FILE} — run the full installer first"
|
||||||
set -a; source <(grep -v '^#' "$CREDS_FILE" | grep '='); set +a
|
# Read key=value pairs safely — handles values that contain spaces (e.g. SITE_NAME)
|
||||||
|
while IFS= read -r line; do
|
||||||
|
[[ "$line" =~ ^[A-Z_][A-Z0-9_]*= ]] || continue
|
||||||
|
key="${line%%=*}"; value="${line#*=}"
|
||||||
|
export "$key"="$value"
|
||||||
|
done < "$CREDS_FILE"
|
||||||
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=""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue