From 60b7c0987e29c9921667d2e84a20a3d16d76b542 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Fri, 12 Oct 2018 11:48:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Adds=20suport=20to=20use=20an=20existi?= =?UTF-8?q?ng=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++++++++ tautulli/config.json | 3 ++- .../rootfs/etc/cont-init.d/20-preparations.sh | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d91cfd..b437a1a 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,17 @@ panel_iframe: 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 This repository keeps a change log using [GitHub's releases][releases] diff --git a/tautulli/config.json b/tautulli/config.json index 5411c48..b210a22 100644 --- a/tautulli/config.json +++ b/tautulli/config.json @@ -22,7 +22,8 @@ }, "map": [ "config", - "ssl" + "ssl", + "share:rw" ], "options": { "log_level": "info", diff --git a/tautulli/rootfs/etc/cont-init.d/20-preparations.sh b/tautulli/rootfs/etc/cont-init.d/20-preparations.sh index 0d9cf47..07586c8 100644 --- a/tautulli/rootfs/etc/cont-init.d/20-preparations.sh +++ b/tautulli/rootfs/etc/cont-init.d/20-preparations.sh @@ -6,8 +6,10 @@ # shellcheck disable=SC1091 source /usr/lib/hassio-addons/base.sh -CONFIG=/data/config.ini -ADDON=/data/addon.ini +readonly 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 ! hass.file_exists "/data/config.ini"; then @@ -71,3 +73,14 @@ fi # Changing config.ini back. ## 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" + +# 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