mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-21 05:20:31 +02:00
Update 90-config_yaml.sh
This commit is contained in:
@@ -8,12 +8,14 @@ set -e
|
|||||||
##################
|
##################
|
||||||
|
|
||||||
# Where is the config
|
# Where is the config
|
||||||
|
if bashio::config.has_value 'CONFIG_LOCATION'; then
|
||||||
|
|
||||||
|
# Get config source
|
||||||
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
||||||
# Check CONFIGSOURCE ends with config.yaml
|
# Check CONFIGSOURCE ends with config.yaml
|
||||||
if [ "$(basename "$CONFIGSOURCE")" != "config.yaml" ]; then
|
if [ "$(basename "$CONFIGSOURCE")" != "config.yaml" ]; then
|
||||||
bashio::log.error "Watchout: your CONFIG_LOCATION should end by config.yaml, and instead it is $(basename "$CONFIGSOURCE")"
|
bashio::log.error "Watchout: your CONFIG_LOCATION should end by config.yaml, and instead it is $(basename "$CONFIGSOURCE")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if config is located in an acceptable location
|
# Check if config is located in an acceptable location
|
||||||
LOCATIONOK=""
|
LOCATIONOK=""
|
||||||
for location in "/share" "/config" "/data"; do
|
for location in "/share" "/config" "/data"; do
|
||||||
@@ -21,17 +23,22 @@ for location in "/share" "/config" "/data"; do
|
|||||||
LOCATIONOK=true
|
LOCATIONOK=true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$LOCATIONOK" ]; then
|
if [ -z "$LOCATIONOK" ]; then
|
||||||
CONFIGSOURCE=/config/addons_config/${HOSTNAME#*-}
|
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"
|
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
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
# Use default
|
||||||
|
CONFIGSOURCE="/config/addons_config/${HOSTNAME#*-}"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if config file is there, or create one from template
|
# Check if config file is there, or create one from template
|
||||||
if [ -f "$CONFIGSOURCE" ]; then
|
if [ -f "$CONFIGSOURCE" ]; then
|
||||||
echo "Using config file found in $CONFIGSOURCE"
|
echo "... using config file found in $CONFIGSOURCE"
|
||||||
else
|
else
|
||||||
echo "No config file, creating one from template"
|
echo "... no config file, creating one from template"
|
||||||
# Create folder
|
# Create folder
|
||||||
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
||||||
# Placing template in config
|
# Placing template in config
|
||||||
|
|||||||
Reference in New Issue
Block a user