mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-30 20:34:04 +02:00
Update 99-run.sh
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user