Fix credentials loading to handle values with spaces
This commit is contained in:
parent
285d6609b1
commit
76f5276f4b
2 changed files with 13 additions and 4 deletions
|
|
@ -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 ────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue