mirror of
https://github.com/hassio-addons/addon-tautulli.git
synced 2025-05-03 18:41:30 +00:00
🔨 Migrate old-style S6 scripts to s6-rc.d (#259)
This commit is contained in:
parent
7faf14c77a
commit
fb43c48915
12 changed files with 84 additions and 62 deletions
|
@ -1,51 +1 @@
|
|||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Tautulli
|
||||
# Preparing configuration for Tautulli
|
||||
# ==============================================================================
|
||||
readonly ADDON=/data/addon.ini
|
||||
readonly CONFIG=/data/config.ini
|
||||
|
||||
# Check SSL cerrificate
|
||||
bashio::config.require.ssl
|
||||
|
||||
# If config.ini does not exist, create it.
|
||||
if ! bashio::fs.file_exists "$CONFIG"; then
|
||||
bashio::log.info "Creating default configuration..."
|
||||
crudini --set "$CONFIG" Advanced system_analytics 0
|
||||
crudini --set "$CONFIG" General backup_dir "/backup/tautulli"
|
||||
crudini --set "$CONFIG" General first_run_complete 0
|
||||
crudini --set "$CONFIG" General update_show_changelog 0
|
||||
crudini --set "$ADDON" Addon version "$TAUTULLI_VERSION"
|
||||
fi
|
||||
|
||||
# Create backup directory
|
||||
mkdir -p /backup/tautulli
|
||||
|
||||
bashio::log.info "Updating running configuration..."
|
||||
|
||||
# Temporrary changing config.ini to be valid during additions
|
||||
## 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
|
||||
if ! bashio::fs.file_exists "/data/addon.ini"; then
|
||||
crudini --set "$ADDON" Addon version "0"
|
||||
fi
|
||||
CURRENT_VERSION=$(crudini --get "$ADDON" Addon version)
|
||||
if [ "$CURRENT_VERSION" != "$TAUTULLI_VERSION" ]; then
|
||||
bashio::log.debug "This is an upgrade..."
|
||||
crudini --set "$CONFIG" General update_show_changelog 1
|
||||
else
|
||||
bashio::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
|
||||
|
||||
# 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"
|
||||
|
|
52
tautulli/rootfs/etc/s6-overlay/s6-rc.d/init-tautulli/run
Executable file
52
tautulli/rootfs/etc/s6-overlay/s6-rc.d/init-tautulli/run
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Tautulli
|
||||
# Preparing configuration for Tautulli
|
||||
# ==============================================================================
|
||||
readonly ADDON=/data/addon.ini
|
||||
readonly CONFIG=/data/config.ini
|
||||
|
||||
# Check SSL cerrificate
|
||||
bashio::config.require.ssl
|
||||
|
||||
# If config.ini does not exist, create it.
|
||||
if ! bashio::fs.file_exists "$CONFIG"; then
|
||||
bashio::log.info "Creating default configuration..."
|
||||
crudini --set "$CONFIG" Advanced system_analytics 0
|
||||
crudini --set "$CONFIG" General backup_dir "/backup/tautulli"
|
||||
crudini --set "$CONFIG" General first_run_complete 0
|
||||
crudini --set "$CONFIG" General update_show_changelog 0
|
||||
crudini --set "$ADDON" Addon version "$TAUTULLI_VERSION"
|
||||
fi
|
||||
|
||||
# Create backup directory
|
||||
mkdir -p /backup/tautulli
|
||||
|
||||
bashio::log.info "Updating running configuration..."
|
||||
|
||||
# Temporrary changing config.ini to be valid during additions
|
||||
## 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
|
||||
if ! bashio::fs.file_exists "/data/addon.ini"; then
|
||||
crudini --set "$ADDON" Addon version "0"
|
||||
fi
|
||||
CURRENT_VERSION=$(crudini --get "$ADDON" Addon version)
|
||||
if [ "$CURRENT_VERSION" != "$TAUTULLI_VERSION" ]; then
|
||||
bashio::log.debug "This is an upgrade..."
|
||||
crudini --set "$CONFIG" General update_show_changelog 1
|
||||
else
|
||||
bashio::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
|
||||
|
||||
# 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"
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
1
tautulli/rootfs/etc/s6-overlay/s6-rc.d/init-tautulli/up
Normal file
1
tautulli/rootfs/etc/s6-overlay/s6-rc.d/init-tautulli/up
Normal file
|
@ -0,0 +1 @@
|
|||
/etc/s6-overlay/s6-rc.d/init-tautulli/run
|
27
tautulli/rootfs/etc/s6-overlay/s6-rc.d/tautulli/finish
Executable file
27
tautulli/rootfs/etc/s6-overlay/s6-rc.d/tautulli/finish
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Tautulli
|
||||
# Take down the S6 supervision tree when Tautulli fails
|
||||
# ==============================================================================
|
||||
declare exit_code
|
||||
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
|
||||
readonly exit_code_service="${1}"
|
||||
readonly exit_code_signal="${2}"
|
||||
readonly service="Tautulli"
|
||||
|
||||
bashio::log.info \
|
||||
"Service ${service} exited with code ${exit_code_service}" \
|
||||
"(by signal ${exit_code_signal})"
|
||||
|
||||
if [[ "${exit_code_service}" -eq 256 ]]; then
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
|
||||
elif [[ "${exit_code_service}" -ne 0 ]]; then
|
||||
if [[ "${exit_code_container}" -eq 0 ]]; then
|
||||
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
|
||||
fi
|
||||
exec /run/s6/basedir/bin/halt
|
||||
fi
|
|
@ -1,4 +1,5 @@
|
|||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Tautulli
|
||||
# Runs Tautulli
|
||||
|
@ -8,4 +9,4 @@ exec \
|
|||
python3 /opt/Tautulli.py \
|
||||
--datadir /data \
|
||||
--nolaunch \
|
||||
-p 8181
|
||||
-p 8181
|
1
tautulli/rootfs/etc/s6-overlay/s6-rc.d/tautulli/type
Normal file
1
tautulli/rootfs/etc/s6-overlay/s6-rc.d/tautulli/type
Normal file
|
@ -0,0 +1 @@
|
|||
longrun
|
|
@ -1,11 +0,0 @@
|
|||
#!/command/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-on: Tautulli
|
||||
# Take down the S6 supervision tree when Tautulli fails
|
||||
# ==============================================================================
|
||||
if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then
|
||||
bashio::log.warning "Tautulli crashed, halting add-on"
|
||||
/run/s6/basedir/bin/halt
|
||||
fi
|
||||
|
||||
bashio::log.info "Tautulli stopped, restarting..."
|
Loading…
Add table
Add a link
Reference in a new issue