From a657b21e3bf11b1e6d9861b76d09bcfacd076045 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 2 Dec 2021 13:21:45 +0100 Subject: [PATCH] Update 99-run.sh --- gazpar2mqtt/rootfs/scripts/99-run.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gazpar2mqtt/rootfs/scripts/99-run.sh b/gazpar2mqtt/rootfs/scripts/99-run.sh index 8b8ed5fcb..490792c4d 100644 --- a/gazpar2mqtt/rootfs/scripts/99-run.sh +++ b/gazpar2mqtt/rootfs/scripts/99-run.sh @@ -63,9 +63,24 @@ function parse_yaml { # Get variables and export bashio::log.info "Starting the app with the variables in /config/gazpar2mqtt" -for word in $(parse_yaml "$CONFIGSOURCE" ""); do +# Get list of parameters in a file +eval parse_yaml "$CONFIGSOURCE" "" >/tmpfile +while IFS= read -r line +do # Clean output word=${word//[\"\']/} + # Check if secret + if [[ "${word}" == *'!secret '* ]]; then + echo "Secret detected $word" + key="${word%%=*}" + echo "word: $word" + secret=${word#*secret } + echo "secret : $secret" + eval parse_yaml "/config/secrets.yaml" "" >/secrettmp + secret=$(sed "/$secret/!d" /secrettmp) + rm /secrettmp + word="$key=$secret" + fi # Data validation if [[ $word =~ ^.+[=].+$ ]]; then export $word # Export the variable @@ -74,7 +89,7 @@ for word in $(parse_yaml "$CONFIGSOURCE" ""); do bashio::log.fatal "$word does not follow the structure KEY=text, it will be ignored and removed from the config" sed -i "/$word/ d" ${CONFIGSOURCE} fi -done +done < "/tmpfile" ############## # Launch App #