Improve logic

This commit is contained in:
Alexandre
2024-10-11 17:12:48 +02:00
committed by GitHub
parent 8f9b1fb466
commit 3802f2c97e

View File

@@ -13,22 +13,22 @@ fi
# Define slug
slug="${HOSTNAME/-/_}"
slug="${slug#*_}"
# Check type of config folder
if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then
# New config location
CONFIGLOCATION="/config"
CONFIGFILEBROWSER="/addon_configs/$slug/${HOSTNAME#*_}.sh"
CONFIGFILEBROWSER="/addon_configs/${HOSTNAME/-/_}/$slug.sh"
else
# Legacy config location
slug="${HOSTNAME#*_}"
CONFIGLOCATION="/config/addons_autoscripts"
CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/${slug}.sh"
CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/$slug.sh"
fi
# Default location
mkdir -p "$CONFIGLOCATION" || true
CONFIGSOURCE="$CONFIGLOCATION/${HOSTNAME#*_}.sh"
CONFIGSOURCE="$CONFIGLOCATION/$slug.sh"
bashio::log.green "Execute $CONFIGFILEBROWSER if existing"
bashio::log.green "Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation"