diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index bf094a48f..b7fe110aa 100644 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -144,24 +144,25 @@ while IFS= read -r line; do fi # Check if secret - if [[ "${line}" == *'!secret '* ]]; then - echo "secret detected" - if [ ! -f "$SECRETSFILE" ]; then - bashio:log.fatal "Secrets file not found, ${line} skipped" - continue - fi - secret=${line#*secret } - # Check if single match - 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" "$SECRETSFILE") - secret=${secret#*: } - line="${line%%=*}='$secret'" + if [[ "$line" == *!secret* ]]; then + echo "Secret detected" + if [ ! -f "$SECRETSFILE" ]; then + bashio::log.fatal "Secrets file not found in $SECRETSFILE, $line skipped" + continue + fi + secret=$(echo "$line" | sed 's/.*!secret \(.*\)/\1/') + # Check if single match + secretnum=$(sed -n "/$secret:/=" "$SECRETSFILE") + if [[ $(echo "$secretnum" | grep -q ' ') ]]; then + bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file" + fi + # Get text + secret_value=$(sed -n "/$secret:/s/.*: //p" "$SECRETSFILE") + line="${line%%=*}='$secret_value'" fi # Data validation - if [[ "$line" =~ ^.+[=].+$ ]]; then + if [[ "$line" =~ ^[^[:space:]]+.+[=].+$ ]]; then # extract keys and values KEYS="${line%%=*}" VALUE="${line#*=}"