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")
DATABASESOURCE=$(dirname "${CONFIGSOURCE}")/database.sqlite
# Remoce config in data if existing
[ -f /data/config.yaml ] && rm /data/config.yaml
# Make sure folder exist
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
if [ -f $CONFIGSOURCE ]; then
@@ -27,7 +33,6 @@ if [ -f $CONFIGSOURCE ]; then
fi
else
# Create symlink for addon to create config
mkdir -p "$(dirname "${CONFIGSOURCE}")"
touch ${CONFIGSOURCE}
ln -s $CONFIGSOURCE /data
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."
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
if [ -f $DATABASESOURCE ]; then
ln -s $CONFIGSOURCE /data
bashio::log.info "Using database file found in $DATABASESOURCE"
else
# Create symlink for addon to create database
mkdir -p "$(dirname "${DATABASESOURCE}")"
touch ${DATABASESOURCE}
ln -s $DATABASESOURCE /data
rm $DATABASESOURCE