From 805fe3a9fdaef87100ca880a95556782bab7491a Mon Sep 17 00:00:00 2001 From: alexbelgium Date: Thu, 29 May 2025 15:59:41 +0200 Subject: [PATCH] Improve --- immich/rootfs/etc/cont-init.d/99-run.sh | 36 ++++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/immich/rootfs/etc/cont-init.d/99-run.sh b/immich/rootfs/etc/cont-init.d/99-run.sh index 9f3e804a4..614e3e07c 100755 --- a/immich/rootfs/etc/cont-init.d/99-run.sh +++ b/immich/rootfs/etc/cont-init.d/99-run.sh @@ -8,7 +8,7 @@ export_options() { local json_source="/data/options.json" bashio::log.info "Exporting addon options from ${json_source}" - # Get all keys and export their raw values + # WARNING: Exporting all keys can cause trouble if your config contains unsafe or untrusted keys! mapfile -t keys < <(jq -r 'keys[]' "${json_source}") for key in "${keys[@]}"; do local value @@ -24,7 +24,7 @@ export_options() { # Function to check and adjust DB_HOSTNAME if necessary check_db_hostname() { - if [[ "$DB_HOSTNAME" == "homeassistant.local" ]]; then + if [[ "${DB_HOSTNAME}" == "homeassistant.local" ]]; then local host_ip host_ip=$(bashio::network.ipv4_address) host_ip=${host_ip%/*} @@ -74,7 +74,9 @@ validate_config() { export_db_env() { if [ -d /var/run/s6/container_environment ]; then for var in DB_USERNAME DB_PASSWORD DB_DATABASE_NAME DB_PORT DB_HOSTNAME JWT_SECRET; do - printf "%s" "${!var}" > "/var/run/s6/container_environment/${var}" + if [ -n "${!var:-}" ]; then + printf "%s" "${!var}" > "/var/run/s6/container_environment/${var}" + fi done fi } @@ -87,7 +89,7 @@ setup_root_user() { else bashio::log.warning "DB_ROOT_PASSWORD not set. Generating a random 12-character alphanumeric password and storing it in the addon options." export DB_ROOT_PASSWORD="$(tr -dc 'A-Za-z0-9'