From 5d2645ca4d0f7e2cb55a780ceb70f86c37ebfda8 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Fri, 12 Jan 2024 20:37:44 +0100 Subject: [PATCH] Change config location https://github.com/alexbelgium/hassio-addons/issues/1177 --- calibre_web/CHANGELOG.md | 20 ++++++++++++++++++ calibre_web/Dockerfile | 4 ++-- calibre_web/config.json | 8 +++---- .../rootfs/etc/cont-init.d/00-a_migrate.sh | 13 ++++++++++++ .../etc/cont-init.d/00-data_location.sh | 21 ++++++++++++++----- .../rootfs/etc/cont-init.d/20-folders.sh | 8 +++---- .../etc/cont-init.d/80-configuration.sh | 4 ++-- 7 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 calibre_web/rootfs/etc/cont-init.d/00-a_migrate.sh diff --git a/calibre_web/CHANGELOG.md b/calibre_web/CHANGELOG.md index 67b4f9e63..537949f72 100644 --- a/calibre_web/CHANGELOG.md +++ b/calibre_web/CHANGELOG.md @@ -1,52 +1,72 @@ +- ⚠ MAJOR CHANGE : switch to the new config logic from homeassistant. Your configuration files will have migrated from /config/hassio_addons/calibre-web to a folder only accessible from my Filebrowser addon called /addon_configs/something-calibre-web. This avoids the addon to mess with your homeassistant configuration folder, and allows to backup the options. Migration of data, custom configs, and custom scripts should be automatic. Please be sure to update all your links however ! For more information, see here : https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/ https://github.com/alexbelgium/hassio-addons/issues/1177 + ### 0.6.21-2 (05-11-2023) + - Minor bugs fixed - Fix : https://github.com/alexbelgium/hassio-addons/issues/1050 @klassm ## 0.6.21 (28-10-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20 (26-08-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls225 (26-08-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls224 (19-08-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls222 (12-08-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls221 (05-08-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls220 (23-07-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls219 (22-07-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls218 (15-07-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls217 (08-07-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls216 (01-07-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls215 (24-06-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls214 (17-06-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls213 (10-06-2023) + - Update to latest version from linuxserver/docker-calibre-web ## 0.6.20-ls212 (03-06-2023) + - Update to latest version from linuxserver/docker-calibre-web + ### 0.6.20-ls211-2 (30-05-2023) + - Minor bugs fixed - Fix : allow app to start on clean install @PaulAmor https://github.com/alexbelgium/hassio-addons/issues/850 diff --git a/calibre_web/Dockerfile b/calibre_web/Dockerfile index 519405fb2..62eb6fd08 100644 --- a/calibre_web/Dockerfile +++ b/calibre_web/Dockerfile @@ -37,12 +37,12 @@ RUN \ # Global LSIO modifications ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" "/ha_lsio.sh" -ARG CONFIGLOCATION="/config/addons_config/calibre-web" +ARG CONFIGLOCATION="/config" RUN chmod 744 /ha_lsio.sh && if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi && rm /ha_lsio.sh # Specific images modifications RUN \ - usermod --home /config/addons_config/calibre abc + usermod --home /config abc ################## # 3 Install apps # diff --git a/calibre_web/config.json b/calibre_web/config.json index b2195971b..9aff5ddc8 100644 --- a/calibre_web/config.json +++ b/calibre_web/config.json @@ -59,11 +59,11 @@ ], "environment": { "DOCKER_MODS": "linuxserver/mods:universal-calibre", - "FM_HOME": "/config/addons_config/calibre-web", - "HOME": "/config/addons_config/calibre-web", + "FM_HOME": "/config", + "HOME": "/config", "PGID": "0", "PUID": "0", - "calibre-web_CONFIG_DIRECTORY": "/config/addons_config/calibre-web", + "calibre-web_CONFIG_DIRECTORY": "/config", "shm_size": "1gb" }, "hassio_api": true, @@ -110,6 +110,6 @@ "slug": "calibre-web", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons/tree/master/calibre_web", - "version": "0.6.21-4", + "version": "0.6.21-5", "video": true } diff --git a/calibre_web/rootfs/etc/cont-init.d/00-a_migrate.sh b/calibre_web/rootfs/etc/cont-init.d/00-a_migrate.sh new file mode 100644 index 000000000..23231623d --- /dev/null +++ b/calibre_web/rootfs/etc/cont-init.d/00-a_migrate.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +set -e + +#################### +# Migrate database # +#################### + +if [ -d /homeassistant/addons_config/calibre-web ]; then + echo "Moving database to new location /config" + cp -rf /homeassistant/addons_config/calibre-web/* /config/ + rm -r /homeassistant/addons_config/calibre-web +fi diff --git a/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh b/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh index 25757af97..12fc9d7f9 100755 --- a/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh +++ b/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh @@ -11,7 +11,7 @@ LOCATION=$(bashio::config 'data_location') if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then # Default location - LOCATION="/config/addons_config/calibre-web" + LOCATION="/config" else bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually" @@ -24,7 +24,7 @@ else done if [ -z "$LOCATIONOK" ]; then - LOCATION=/config/addons_config/${HOSTNAME#*-} + LOCATION=/config bashio::log.fatal "Your data_location value can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $LOCATION" fi @@ -34,9 +34,9 @@ fi bashio::log.info "Setting data location to $LOCATION" sed -i "1a export HOME=$LOCATION" /etc/services.d/*/run sed -i "1a export FM_HOME=$LOCATION" /etc/services.d/*/run -sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /defaults/* -sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /etc/cont-init.d/* -sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /etc/services.d/*/run +sed -i "s|/config|$LOCATION|g" /defaults/* +sed -i "s|/config|$LOCATION|g" /etc/cont-init.d/* +sed -i "s|/config|$LOCATION|g" /etc/services.d/*/run if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME; fi if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME; fi printf "%s" "HOME=\"$LOCATION\"" >> ~/.bashrc @@ -51,3 +51,14 @@ mkdir -p "$LOCATION" # Set ownership bashio::log.info "Setting ownership to $PUID:$PGID" chown "$PUID":"$PGID" "$LOCATION" + +#################### +# Migrate database # +#################### + +if [ -d /homeassistant/addons_config/calibre-web ]; then + echo "Moving database to new location /config" + cp -rf /homeassistant/addons_config/calibre-web/* "$LOCATION"/ + rm -r /homeassistant/addons_config/calibre-web +fi + diff --git a/calibre_web/rootfs/etc/cont-init.d/20-folders.sh b/calibre_web/rootfs/etc/cont-init.d/20-folders.sh index 1674453d5..da450e78b 100755 --- a/calibre_web/rootfs/etc/cont-init.d/20-folders.sh +++ b/calibre_web/rootfs/etc/cont-init.d/20-folders.sh @@ -1,8 +1,8 @@ #!/bin/bash -if [ ! -d /config/addons_config/calibre-web ]; then - echo "Creating /config/addons_config/calibre-web" - mkdir -p /config/addons_config/calibre-web +if [ ! -d /config ]; then + echo "Creating /config" + mkdir -p /config fi -chown -R "$PUID:$PGID" /config/addons_config/calibre-web +chown -R "$PUID:$PGID" /config diff --git a/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh b/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh index 971f25c3e..1dca6cb8d 100755 --- a/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh +++ b/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh @@ -14,10 +14,10 @@ bashio::log.info "Install libnss3" apt-get update && apt-get install libnss3 &>/dev/null # Set Ingress login -if [ ! -f /config/addons_config/calibre-web/app.db ]; then +if [ ! -f /config/app.db ]; then bashio::log.warning "First boot : disabling Ingress until addon restart" else - sqlite3 /config/addons_config/calibre-web/app.db 'update settings set config_reverse_proxy_login_header_name="X-WebAuth-User",config_allow_reverse_proxy_header_login=1' + sqlite3 /config/app.db 'update settings set config_reverse_proxy_login_header_name="X-WebAuth-User",config_allow_reverse_proxy_header_login=1' fi bashio::log.info "Default username:password is admin:admin123"