From e12b45a9a4c7c6f327ada04561e2a6d97e844d85 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 20 Feb 2022 11:34:52 +0100 Subject: [PATCH] Add default value if config location not correct https://github.com/alexbelgium/hassio-addons/issues/223 --- .templates/90-config_yaml.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.templates/90-config_yaml.sh b/.templates/90-config_yaml.sh index 722803b2b..3743c2929 100644 --- a/.templates/90-config_yaml.sh +++ b/.templates/90-config_yaml.sh @@ -10,15 +10,17 @@ CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") # Check if config is located in an acceptable location -#for location in "/share" "/config" "/data" -#if [[ "$CONFIGSOURCE" == "$location"* ]]; then -#LOCATIONOK=true -#fi -#done -#if [ ! "$LOCATIONOK" = "true" ]; then -#CONFIGSOURCE= -#bashio::log.fatal "Your CONFIG_LOCATION values can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $CONFIGSOURCE" -#fi +LOCATIONOK="" +for location in "/share" "/config" "/data"; do + if [[ "$CONFIGSOURCE" == "$location"* ]]; then + LOCATIONOK=true + fi +done + +if [ -z "$LOCATIONOK" ]; then + CONFIGSOURCE=/config/addons_config/${HOSTNAME#*-} + bashio::log.fatal "Your CONFIG_LOCATION values can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $CONFIGSOURCE" +fi # Check if config file is there, or create one from template if [ -f "$CONFIGSOURCE" ]; then