This commit is contained in:
Alexandre
2024-01-12 20:37:44 +01:00
parent 6434f0e1a6
commit 5d2645ca4d
7 changed files with 61 additions and 17 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"