From 7cc1afd85d40f9d7f743442a0fe73ee6ffd36390 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 25 Jan 2023 05:56:11 +0100 Subject: [PATCH] Add secrets to config.yaml https://github.com/m4dm4rtig4n/myelectricaldata/issues/288 --- .templates/00-global_var.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.templates/00-global_var.sh b/.templates/00-global_var.sh index 7c46e2e08..ee075c638 100755 --- a/.templates/00-global_var.sh +++ b/.templates/00-global_var.sh @@ -16,6 +16,18 @@ for KEYS in "${arr[@]}"; do # export key VALUE=$(jq ."$KEYS" "${JSONSOURCE}") line="${KEYS}='${VALUE//[\"\']/}'" + # Check if secret + if [[ "${line}" == *'!secret '* ]]; then + echo "secret detected" + secret=${line#*secret } + # Check if single match + secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) + [[ $(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=${secret#*: } + line="${line%%=*}='$secret'" + fi # text if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then bashio::log.blue "${KEYS}=******"