Update 99-run.sh

This commit is contained in:
Alexandre
2021-11-17 23:01:38 +01:00
committed by GitHub
parent f265a32087
commit dbd3c48488

View File

@@ -8,8 +8,14 @@
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
DATABASESOURCE=$(dirname "${CONFIGSOURCE}")/database.sqlite DATABASESOURCE=$(dirname "${CONFIGSOURCE}")/database.sqlite
# Remoce config in data if existing # Make sure folder exist
[ -f /data/config.yaml ] && rm /data/config.yaml mkdir -p "$(dirname "${CONFIGSOURCE}")"
mkdir -p "$(dirname "${DATABASESOURCE}")"
# Use existing config if present
if [ -f /data/config.yaml ]; then
mv /data/config.yaml $(dirname "${CONFIGSOURCE}")
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
@@ -27,7 +33,6 @@ if [ -f $CONFIGSOURCE ]; then
fi fi
else else
# Create symlink for addon to create config # Create symlink for addon to create config
mkdir -p "$(dirname "${CONFIGSOURCE}")"
touch ${CONFIGSOURCE} touch ${CONFIGSOURCE}
ln -s $CONFIGSOURCE /data ln -s $CONFIGSOURCE /data
rm $CONFIGSOURCE rm $CONFIGSOURCE
@@ -35,13 +40,17 @@ else
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
# Use existing database if present
if [ -f /data/database.sqlite ]; then
mv /data/database.sqlite $(dirname "${DATABASESOURCE}")
fi
# Check if database is here or create symlink # Check if database is here or create symlink
if [ -f $DATABASESOURCE ]; then if [ -f $DATABASESOURCE ]; then
ln -s $CONFIGSOURCE /data ln -s $CONFIGSOURCE /data
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
mkdir -p "$(dirname "${DATABASESOURCE}")"
touch ${DATABASESOURCE} touch ${DATABASESOURCE}
ln -s $DATABASESOURCE /data ln -s $DATABASESOURCE /data
rm $DATABASESOURCE rm $DATABASESOURCE