mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-17 21:09:13 +02:00
Migrate logic to use /data/cache.db
https://github.com/alexbelgium/hassio-addons/issues/600
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# Where is the config
|
# Where is the config
|
||||||
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
||||||
DATABASESOURCE="$(dirname "${CONFIGSOURCE}")/enedisgateway.db"
|
DATABASESOURCE="$(dirname "${CONFIGSOURCE}")/cache.db"
|
||||||
|
|
||||||
# Make sure folder exist
|
# Make sure folder exist
|
||||||
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
mkdir -p "$(dirname "${CONFIGSOURCE}")"
|
||||||
@@ -44,14 +44,18 @@ 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
|
||||||
|
|
||||||
# Remove previous link or file
|
# Fetch the migrated versions and copy it in the new database location
|
||||||
[ -f /data/enedisgateway.db ] && rm /data/enedisgateway.db
|
if [ -f /data/enedisgateway.db.migrate ]; then
|
||||||
|
bashio::log.warning "Migration performed, enedisgateway.db.migrate copied in $(dirname "${CONFIGSOURCE}")"
|
||||||
|
mv /data/enedisgateway.db.migrate "$(dirname "${CONFIGSOURCE}")"
|
||||||
|
mv /data/cache.db "$(dirname "${CONFIGSOURCE}")"
|
||||||
|
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
|
||||||
# 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 $(dirname "${CONFIGSOURCE}")"
|
||||||
else
|
else
|
||||||
# Create symlink for addon to create database
|
# Create symlink for addon to create database
|
||||||
touch "${DATABASESOURCE}"
|
touch "${DATABASESOURCE}"
|
||||||
|
|||||||
Reference in New Issue
Block a user