From c1394193558760648d64997a6506606a8bf722c5 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 2 Jul 2025 14:50:20 +0200 Subject: [PATCH] Try alternative code https://github.com/alexbelgium/hassio-addons/issues/1933 --- .templates/01-config_yaml.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index 6be190683..1600dd497 100755 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -164,7 +164,10 @@ if [ -f "$SECRETSFILE" ]; then SECRETSFILE="/homeassistant/secrets.yaml"; fi while IFS= read -r line; do # Clean output - line="${line//[\"\']/}" + if [[ $line == \"*\" ]]; then + line="${line:1:-1}" + fi + # Check if secret if [[ "${line}" == *'!secret '* ]]; then echo "secret detected" @@ -183,11 +186,11 @@ while IFS= read -r line; do KEYS="${line%%=*}" VALUE="${line#*=}" line="${KEYS}='${VALUE}'" - export "$line" + export "${KEY}=${VALUE}" # export to python if command -v "python3" &>/dev/null; then [ ! -f /env.py ] && echo "import os" >/env.py - echo "os.environ['${KEYS}'] = '${VALUE//[\"\']/}'" >>/env.py + echo "os.environ['${KEY}'] = '${VALUE//\'/\\\'}'" >> /env.py python3 /env.py fi # set .env @@ -198,7 +201,7 @@ while IFS= read -r line; do if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null; fi if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi # For s6 - if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" >/var/run/s6/container_environment/"${KEYS}"; fi + if [ -d /var/run/s6/container_environment ]; then printf "%s='%s'\n" "$KEY" "$VALUE" >> /etc/environment; fi echo "export $line" >>~/.bashrc # Show in log if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi