From 3100d33ac61636c6a0b96dc53524ce6b212d1d6e Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 19 Nov 2023 16:57:18 +0100 Subject: [PATCH] Update code --- .templates/01-config_yaml.sh | 11 +++++++---- .templates/01-custom_script.sh | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.templates/01-config_yaml.sh b/.templates/01-config_yaml.sh index f1b020946f8..fbd5917ea71 100755 --- a/.templates/01-config_yaml.sh +++ b/.templates/01-config_yaml.sh @@ -12,6 +12,9 @@ if [ ! -d /config ]; then exit 0 fi +# Define slug if +slug="${HOSTNAME#*-}" + # Check type of config folder if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then # New config location @@ -38,20 +41,20 @@ if bashio::config.has_value 'CONFIG_LOCATION'; then fi done if [ -z "$LOCATIONOK" ]; then - CONFIGSOURCE="$CONFIGLOCATION/${HOSTNAME#*-}" + CONFIGSOURCE="$CONFIGLOCATION/${slug}" bashio::log.red "Watch-out : 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 else # Use default - CONFIGSOURCE="$CONFIGLOCATION/${HOSTNAME#*-}/config.yaml" + CONFIGSOURCE="$CONFIGLOCATION/${slug}/config.yaml" fi # Migrate if needed if [ "$CONFIGLOCATION" == "/config" ]; then - if [ -f "/config/addons_config/${HOSTNAME#*-}/config.yaml" ]; then + if [ -f "/homeassistant/addons_config/${slug}/config.yaml" ]; then echo "Migrating config.yaml to new config location" - mv /config/addons_config/${HOSTNAME#*-}/config.yaml /config/config.yaml + mv /homeassistant/addons_config/"${slug}"/config.yaml /config/config.yaml fi fi diff --git a/.templates/01-custom_script.sh b/.templates/01-custom_script.sh index f343f264cd1..728e95f0f7e 100755 --- a/.templates/01-custom_script.sh +++ b/.templates/01-custom_script.sh @@ -2,13 +2,15 @@ # shellcheck shell=bash set -e +# Define slug if needed slug="${HOSTNAME#*-}" # Check type of config folder if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then # Migrate previous script - if [ -f /config/addons_autoscripts/"${slug}".sh ]; then - mv -f /config/addons_autoscripts/"${slug}".sh /config/"${slug}".sh + if [ -f /config/addons_autoscripts/"${slug}".sh ] && [ -d /homeassistant/addons_autoscripts ]; then + echo "Migrating scripts to new config location" + mv -f /homeassistant/addons_autoscripts/"${slug}".sh /config/"${slug}".sh fi # New config location CONFIGLOCATION="/config"