mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-25 06:13:32 +02:00
Bazarr's config.yaml carries a base_url key under general: (Bazarr's own
ingress path) AND a separate base_url under each configured *arr integration
-- radarr.base_url, sonarr.base_url, etc. -- which is how Bazarr reaches
those services at their own ingress-prefixed URL.
Every base_url sed in this addon was unscoped:
sed -i "s| base_url:.*| base_url: /$slug|" "$CONFIG_LOCATION"
sed applies s/// to every matching line in the file, not just the first, and
" base_url:.*" matches any 2-space-indented base_url line regardless of
which top-level section it's under. Since general.base_url, radarr.base_url,
sonarr.base_url etc. all sit at that same indent, this rewrote all of them to
Bazarr's own value on every container start (32-nginx_ingress.sh) and again
in the run script's fallback -- silently breaking Bazarr's configured
connections to Radarr and Sonarr.
Scope each sed to the general: block only, reusing the range idiom this file
already uses to scope the auth: block's type: substitution:
sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" ...
Verified against a representative config.yaml (general/radarr/sonarr/subsarr
sections, including general:'s list-style provider entries) for all three
connection_mode branches plus the run script's fallback: general.base_url is
the only line touched in every case; radarr.base_url and sonarr.base_url
survive with their original values.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
67 lines
2.9 KiB
Bash
Executable File
67 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/with-contenv bashio
|
|
# shellcheck shell=bash
|
|
set -e
|
|
|
|
#################
|
|
# NGINX SETTING #
|
|
#################
|
|
declare ingress_interface
|
|
declare ingress_port
|
|
|
|
ingress_port=$(bashio::addon.ingress_port)
|
|
ingress_interface=$(bashio::addon.ip_address)
|
|
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=bazarr
|
|
CONFIG_LOCATION=/config/config/config.yaml
|
|
|
|
if [ -f "$CONFIG_LOCATION" ]; then
|
|
|
|
# Define addon mode
|
|
connection_mode="$(bashio::config "connection_mode")"
|
|
bashio::log.green "---------------------------"
|
|
bashio::log.green "Connection_mode is $connection_mode"
|
|
bashio::log.green "---------------------------"
|
|
case "$connection_mode" in
|
|
# Ingress mode, authentication is disabled
|
|
ingress_noauth)
|
|
bashio::log.green "Ingress is enabled, authentication is disabled"
|
|
bashio::log.yellow "WARNING : Make sure that the port is not exposed externally by your router to avoid a security risk !"
|
|
# Set base_url (must start with / for Flask blueprint registration).
|
|
# Scoped to the general: block only -- config.yaml also carries a
|
|
# base_url under each configured *arr integration (radarr.base_url,
|
|
# sonarr.base_url, ...) and those must not be touched.
|
|
sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" "$CONFIG_LOCATION"
|
|
# Disable auth
|
|
sed -i '/^auth:/,/^[^ ]/{ s/ type:.*/ type: null/ }' "$CONFIG_LOCATION"
|
|
;;
|
|
# Ingress mode, with authentication
|
|
ingress_auth)
|
|
bashio::log.green "Ingress is enabled, and external authentication is enabled"
|
|
# Set base_url (must start with / for Flask blueprint registration).
|
|
# Scoped to the general: block only -- see note above.
|
|
sed -i "/^general:/,/^[^ ]/{ s| base_url:.*| base_url: /$slug|; }" "$CONFIG_LOCATION"
|
|
# Enable Bazarr auth when leaving ingress_noauth
|
|
sed -i '/^auth:/,/^[^ ]/{ s/ type:.*/ type: form/ }' "$CONFIG_LOCATION"
|
|
;;
|
|
# No ingress mode, with authentication
|
|
noingress_auth)
|
|
bashio::log.green "Disabling ingress and enabling authentication"
|
|
bashio::log.yellow "WARNING : Ingress is disabled so the app won't be available from HA itself !"
|
|
# Scoped to the general: block only -- see note above.
|
|
sed -i "/^general:/,/^[^ ]/{ s/ base_url:.*/ base_url: ''/; }" "$CONFIG_LOCATION"
|
|
# Enable Bazarr auth when leaving ingress_noauth
|
|
sed -i '/^auth:/,/^[^ ]/{ s/ type:.*/ type: form/ }' "$CONFIG_LOCATION"
|
|
;;
|
|
esac
|
|
|
|
fi
|