Added logic to check if it's the first run after an upgrade. (#3)

This commit is contained in:
Joakim Sørensen 2018-09-05 17:47:54 +02:00 committed by GitHub
parent d5b41cf726
commit 34f8dc441c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 5 deletions

View file

@ -2,6 +2,9 @@ ARG BUILD_FROM=hassioaddons/base:2.1.2
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
# Set env
ENV TAUTULLI_VERSION 'v2.1.18'
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@ -29,7 +32,7 @@ RUN \
pycryptodomex==3.6.6 \
crudini==0.9 \
PyOpenSSL==18.0.0 \
&& git clone --branch "v2.1.18" --depth=1 \
&& git clone --branch $TAUTULLI_VERSION --depth=1 \
https://github.com/Tautulli/Tautulli.git /opt \
&& apk del --purge .build-dependencies \
&& find /usr/lib/python2.7/ -type d -name tests -depth -exec rm -rf {} \; \

View file

@ -7,16 +7,15 @@
source /usr/lib/hassio-addons/base.sh
CONFIG=/data/config.ini
ADDON=/data/addon.ini
# If config.ini does not exist, create it.
if ! hass.file_exists "/data/config.ini"; then
hass.log.info "Creating default configuration..."
crudini --set "$CONFIG" General week_start_monday 1
crudini --set "$CONFIG" General update_show_changelog 0
crudini --set "$CONFIG" General first_run_complete 0
crudini --set "$CONFIG" General check_github 0
crudini --set "$CONFIG" General check_github_on_startup 0
crudini --set "$CONFIG" General update_show_changelog 0
crudini --set "$CONFIG" Advanced system_analytics 0
crudini --set "$ADDON" Addon version "$TAUTULLI_VERSION"
fi
hass.log.info "Updating running configuration..."
@ -25,6 +24,21 @@ hass.log.info "Updating running configuration..."
## 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"
# Set spesific config if an upgrade
CURRENT_VERSION=$(crudini --get "$ADDON" Addon version)
if [ "$CURRENT_VERSION" != "$TAUTULLI_VERSION" ]; then
hass.log.debug "This is an upgrade..."
crudini --set "$CONFIG" General update_show_changelog 1
else
hass.log.debug "This is not an upgrade..."
crudini --set "$CONFIG" General update_show_changelog 0
fi
# Ensure config
crudini --set "$ADDON" Addon version "$TAUTULLI_VERSION"
crudini --set "$CONFIG" General check_github 0
crudini --set "$CONFIG" General check_github_on_startup 0
# Update SSL info in configuration
if hass.config.true 'ssl'; then
hass.log.info "Ensure SSL is active in the configuration..."