From 0fccd5eafb8c57639662c1f5f56bf3ea08d87961 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:38:08 +0100 Subject: [PATCH] Align secrets with new config logic https://github.com/alexbelgium/hassio-addons/issues/1669 https://github.com/alexbelgium/hassio-addons/issues/1163 https://github.com/alexbelgium/hassio-addons/issues/1655 --- .templates/01-config_yaml.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index 43b7d50f816..fdb4773907d 100755 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -157,6 +157,10 @@ parse_yaml "$CONFIGSOURCE" "" >/tmpfile # Escape dollars sed -i 's|$.|\$|g' /tmpfile +# Look where secrets.yaml is located +SECRETSFILE="/config/secrets.yaml" +if [ -f "$SECRETSFILE" ]; then SECRETSFILE="/homeassistant/secrets.yaml"; fi + while IFS= read -r line; do # Clean output line="${line//[\"\']/}" @@ -165,10 +169,10 @@ while IFS= read -r line; do echo "secret detected" secret=${line#*secret } # Check if single match - secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) + secretnum=$(sed -n "/$secret:/=" "$SECRETSFILE") [[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file" # Get text - secret=$(sed -n "/$secret:/p" /config/secrets.yaml) + secret=$(sed -n "/$secret:/p" "$SECRETSFILE") secret=${secret#*: } line="${line%%=*}='$secret'" fi