This commit is contained in:
Alexandre
2023-11-21 09:53:56 +01:00
parent 2e6e4693a7
commit 8e035dde96
350 changed files with 1908 additions and 1328 deletions

View File

@@ -14,3 +14,35 @@ ingress_entry=$(bashio::addon.ingress_entry)
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/nginx/servers/ingress.conf
##################
# CONFIG SETTING #
##################
# Values
slug=readarr
CONFIG_LOCATION=/config/addons_config/"$slug"/config.xml
if [ -f "$CONFIG_LOCATION" ]; then
# Set UrlBase
if ! bashio::config.true "ingress_disabled"; then
bashio::log.warning "---------------------------"
bashio::log.warning "Ingress is enabled, authentification will be disabled and should be managed through HA itself. If you need authentification, please disable ingress in addon options"
bashio::log.warning "---------------------------"
# Define UrlBase
sed -i "/UrlBase/d" "$CONFIG_LOCATION"
sed -i "2a <UrlBase>$slug<\/UrlBase>" "$CONFIG_LOCATION"
# Disable local auth
sed -i "/AuthenticationType/d" "$CONFIG_LOCATION"
sed -i "2a <AuthenticationType>DisabledForLocalAddresses</AuthenticationType>" "$CONFIG_LOCATION"
# Disable local auth
sed -i "/AuthenticationMethod/d" "$CONFIG_LOCATION"
sed -i "2a <AuthenticationMethod>external</AuthenticationMethod>" "$CONFIG_LOCATION"
else
bashio::log.warning "---------------------------"
bashio::log.info "Disabling ingress and enabling authentification"
bashio::log.warning "---------------------------"
sed -i "/UrlBase/d" "$CONFIG_LOCATION"
sed -i "/<AuthenticationMethod>external/d" "$CONFIG_LOCATION"
fi
fi

View File

@@ -19,24 +19,12 @@ if bashio::config.has_value 'CONFIG_LOCATION'; then
fi
# Set UrlBase
if ! grep -q "<UrlBase>/$slug</UrlBase>" "$CONFIG_LOCATION" && ! bashio::config.true "ingress_disabled"; then
if ! grep -q "<UrlBase>$slug</UrlBase>" "$CONFIG_LOCATION" && ! bashio::config.true "ingress_disabled"; then
bashio::log.warning "BaseUrl not set properly, restarting"
sed -i "/UrlBase/d" "$CONFIG_LOCATION"
sed -i "/<Config>/a <UrlBase>\/$slug<\/UrlBase>" "$CONFIG_LOCATION"
sed -i "/<Config>/a <UrlBase>$slug<\/UrlBase>" "$CONFIG_LOCATION"
bashio::addon.restart
fi
# Disable Ingress
if bashio::config.true "ingress_disabled"; then
bashio::log.info "Ingress is disabled, removing base url"
# Remove BaseUrl
if grep -q "$slug" "$CONFIG_LOCATION"; then
bashio::log.warning "BaseUrl removed, restarting"
sed -i "/$slug/d" "$CONFIG_LOCATION"
bashio::addon.restart
fi
fi
bashio::log.info "Starting NGinx..."
exec nginx