diff --git a/immich_frame/rootfs/etc/cont-init.d/99-run.sh b/immich_frame/rootfs/etc/cont-init.d/99-run.sh index c99229c99..1c58b40bd 100755 --- a/immich_frame/rootfs/etc/cont-init.d/99-run.sh +++ b/immich_frame/rootfs/etc/cont-init.d/99-run.sh @@ -13,7 +13,7 @@ fi # Generate Settings.yaml from addon options for multi-account support SETTINGS_FILE="/config/Config/Settings.yaml" -ACCOUNT_COUNT=$(jq '.Accounts | length' /data/options.json 2>/dev/null || echo 0) +ACCOUNT_COUNT=$(jq '.Accounts // [] | length' /data/options.json 2>/dev/null || echo 0) if [ "$ACCOUNT_COUNT" -gt 0 ]; then bashio::log.info "Configuring ${ACCOUNT_COUNT} account(s) from Accounts list" @@ -22,21 +22,29 @@ if [ "$ACCOUNT_COUNT" -gt 0 ]; then for i in $(seq 0 $((ACCOUNT_COUNT - 1))); do SERVER_URL=$(jq -r ".Accounts[${i}].ImmichServerUrl" /data/options.json) API_KEY=$(jq -r ".Accounts[${i}].ApiKey" /data/options.json) + # Escape single quotes for YAML single-quoted strings + SERVER_URL="${SERVER_URL//\'/\'\'}" + API_KEY="${API_KEY//\'/\'\'}" echo " - ImmichServerUrl: '${SERVER_URL}'" echo " ApiKey: '${API_KEY}'" bashio::log.info " Account $((i + 1)): ${SERVER_URL}" done } > "${SETTINGS_FILE}" + chmod 600 "${SETTINGS_FILE}" bashio::log.info "Settings.yaml generated at ${SETTINGS_FILE}" elif bashio::config.has_value 'ApiKey' && bashio::config.has_value 'ImmichServerUrl'; then bashio::log.info "Using single account configuration" SERVER_URL=$(bashio::config 'ImmichServerUrl') API_KEY=$(bashio::config 'ApiKey') + # Escape single quotes for YAML single-quoted strings + SERVER_URL="${SERVER_URL//\'/\'\'}" + API_KEY="${API_KEY//\'/\'\'}" { echo "Accounts:" echo " - ImmichServerUrl: '${SERVER_URL}'" echo " ApiKey: '${API_KEY}'" } > "${SETTINGS_FILE}" + chmod 600 "${SETTINGS_FILE}" bashio::log.info "Settings.yaml generated at ${SETTINGS_FILE}" else bashio::log.fatal "No accounts configured! Set either 'Accounts' list or both 'ApiKey' and 'ImmichServerUrl'"