Fix credentials loading to handle values with spaces

This commit is contained in:
jtricerolph 2026-07-01 19:10:56 +00:00
parent 285d6609b1
commit 76f5276f4b
2 changed files with 13 additions and 4 deletions

View file

@ -25,8 +25,12 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
# Load secrets from credentials file if present
CREDS_FILE=/root/hotel-manage-credentials.txt
if [[ -f "$CREDS_FILE" ]]; then
# shellcheck disable=SC1090
set -a; source <(grep -v '^#' "$CREDS_FILE" | grep '='); set +a
while IFS= read -r line || [[ -n "$line" ]]; do
[[ "$line" =~ ^[[:space:]]*# ]] && continue
[[ -z "${line//[[:space:]]/}" ]] && continue
[[ "$line" =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]] || continue
export "${BASH_REMATCH[1]}"="${BASH_REMATCH[2]}"
done < "$CREDS_FILE"
fi
# ── Collect config ────────────────────────────────────────────────────────────