Adds suport to use an existing database

This commit is contained in:
ludeeus 2018-10-12 11:48:18 +02:00
parent 4aaab20794
commit 60b7c0987e
3 changed files with 28 additions and 3 deletions

View file

@ -166,6 +166,17 @@ panel_iframe:
url: http://addres.to.your.hass.io:8181 url: http://addres.to.your.hass.io:8181
``` ```
## Use an existing database
**NB!: This is considered advanced usage.**
If you want to import an existing Tautulli database to this addon, you first
need to extract the `tautulli.db` file from your existing installation.
Place this file in this directory `/share/tautulli`, you can use samba,
Cloud9 or any other method to move it there.
You need to restart the add-on for it to start using this database.
_if the directory `/share/tautulli` does not exist you need to create it._
## Changelog & Releases ## Changelog & Releases
This repository keeps a change log using [GitHub's releases][releases] This repository keeps a change log using [GitHub's releases][releases]

View file

@ -22,7 +22,8 @@
}, },
"map": [ "map": [
"config", "config",
"ssl" "ssl",
"share:rw"
], ],
"options": { "options": {
"log_level": "info", "log_level": "info",

View file

@ -6,8 +6,10 @@
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh source /usr/lib/hassio-addons/base.sh
CONFIG=/data/config.ini readonly ADDON=/data/addon.ini
ADDON=/data/addon.ini readonly CONFIG=/data/config.ini
readonly DATABASE=/share/tautulli/tautulli.db
readonly SHARE=/share/tautulli
# If config.ini does not exist, create it. # If config.ini does not exist, create it.
if ! hass.file_exists "/data/config.ini"; then if ! hass.file_exists "/data/config.ini"; then
@ -71,3 +73,14 @@ fi
# Changing config.ini back. # Changing config.ini back.
## This has to be done because Tautulli added a ini header with [[header]] ## This has to be done because Tautulli added a ini header with [[header]]
sed -i "s/\\[get_file_sizes_hold\\]/\\[\\[get_file_sizes_hold\\]\\]/" "$CONFIG" sed -i "s/\\[get_file_sizes_hold\\]/\\[\\[get_file_sizes_hold\\]\\]/" "$CONFIG"
# Create /share/tautulli if it does not exist.
if ! hass.directory_exists "$SHARE"; then
mkdir "$SHARE"
fi
# Use databasefile from /share/tautulli if it exist.
if hass.file_exists "$DATABASE"; then
hass.log.info "Using database from $DATABASE"
ln -sf "$DATABASE" /data/tautulli.db
fi