mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-04 14:54:07 +02:00
Update 99-run.sh
This commit is contained in:
@@ -15,19 +15,19 @@ mkdir -p "$(dirname "${DATABASESOURCE}")"
|
|||||||
# Check absence of config file
|
# Check absence of config file
|
||||||
if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then
|
if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then
|
||||||
bashio::log.warning "A current config was found in /data, it is backuped to ${CONFIGSOURCE}.bak"
|
bashio::log.warning "A current config was found in /data, it is backuped to ${CONFIGSOURCE}.bak"
|
||||||
mv /data/config.yaml $CONFIGSOURCE.bak
|
mv /data/config.yaml "$CONFIGSOURCE".bak
|
||||||
fi
|
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
|
||||||
# Create symlink if not existing yet
|
# Create symlink if not existing yet
|
||||||
[ ! -L /data/config.yaml ] && ln -sf $CONFIGSOURCE /data
|
[ ! -L /data/config.yaml ] && ln -sf "$CONFIGSOURCE" /data
|
||||||
bashio::log.info "Using config file found in $CONFIGSOURCE"
|
bashio::log.info "Using config file found in $CONFIGSOURCE"
|
||||||
|
|
||||||
# Check if yaml is valid
|
# Check if yaml is valid
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
yamllint -d relaxed $CONFIGSOURCE &>ERROR || EXIT_CODE=$?
|
yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$?
|
||||||
if [ $EXIT_CODE = 0 ]; then
|
if [ "$EXIT_CODE" = 0 ]; then
|
||||||
echo "Config file is a valid yaml"
|
echo "Config file is a valid yaml"
|
||||||
else
|
else
|
||||||
cat ERROR
|
cat ERROR
|
||||||
@@ -36,9 +36,9 @@ if [ -f $CONFIGSOURCE ]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Create symlink for addon to create config
|
# Create symlink for addon to create config
|
||||||
touch ${CONFIGSOURCE}
|
touch "${CONFIGSOURCE}"
|
||||||
ln -sf $CONFIGSOURCE /data
|
ln -sf "$CONFIGSOURCE" /data
|
||||||
rm $CONFIGSOURCE
|
rm "$CONFIGSOURCE"
|
||||||
# Need to restart
|
# Need to restart
|
||||||
bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting."
|
bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting."
|
||||||
fi
|
fi
|
||||||
@@ -47,15 +47,15 @@ fi
|
|||||||
[ -f /data/enedisgateway.db ] && rm /data/enedisgateway.db
|
[ -f /data/enedisgateway.db ] && rm /data/enedisgateway.db
|
||||||
|
|
||||||
# Check if database is here or create symlink
|
# Check if database is here or create symlink
|
||||||
if [ -f $DATABASESOURCE ]; then
|
if [ -f "$DATABASESOURCE" ]; then
|
||||||
# Create symlink if not existing yet
|
# Create symlink if not existing yet
|
||||||
ln -sf ${DATABASESOURCE} /data && echo "creating symlink"
|
ln -sf "${DATABASESOURCE}" /data && echo "creating symlink"
|
||||||
bashio::log.info "Using database file found in $DATABASESOURCE"
|
bashio::log.info "Using database file found in $DATABASESOURCE"
|
||||||
else
|
else
|
||||||
# Create symlink for addon to create database
|
# Create symlink for addon to create database
|
||||||
touch ${DATABASESOURCE}
|
touch "${DATABASESOURCE}"
|
||||||
ln -sf $DATABASESOURCE /data
|
ln -sf "$DATABASESOURCE" /data
|
||||||
rm $DATABASESOURCE
|
rm "$DATABASESOURCE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##############
|
##############
|
||||||
|
|||||||
Reference in New Issue
Block a user