mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
Improve code
This commit is contained in:
@@ -5,8 +5,10 @@
|
||||
# Wait for transmission to become available
|
||||
bashio::net.wait_for 7878 localhost 900
|
||||
|
||||
# Set Config location
|
||||
CONFIG_LOCATION=/config/addons_config/radarr/config.xml
|
||||
# Set variables
|
||||
slug=radarr
|
||||
CONFIG_LOCATION=/config/addons_config/"$slug"/config.xml
|
||||
|
||||
if bashio::config.has_value 'CONFIG_LOCATION'; then
|
||||
CONFIG_LOCATION="$(bashio::config 'CONFIG_LOCATION')"
|
||||
# Modify if it is a base directory
|
||||
@@ -15,10 +17,10 @@ if bashio::config.has_value 'CONFIG_LOCATION'; then
|
||||
fi
|
||||
|
||||
# Set UrlBase
|
||||
if ! grep -q "<UrlBase>/radarr</UrlBase>" "$CONFIG_LOCATION" && ! bashio::config.true "ingress_disabled"; then
|
||||
if ! grep -q "<UrlBase>/$slug</UrlBase>" "$CONFIG_LOCATION" && ! bashio::config.true "ingress_disabled"; then; then
|
||||
bashio::log.warning "BaseUrl not set properly, restarting"
|
||||
sed -i "/UrlBase/d" "$CONFIG_LOCATION"
|
||||
sed -i "/<Config>/a <UrlBase>\/radarr<\/UrlBase>" "$CONFIG_LOCATION"
|
||||
sed -i "/<Config>/a <UrlBase>\/$slug<\/UrlBase>" "$CONFIG_LOCATION"
|
||||
bashio::addon.restart
|
||||
fi
|
||||
|
||||
@@ -27,9 +29,9 @@ if bashio::config.true "ingress_disabled"; then
|
||||
bashio::log.info "Ingress is disabled, removing base url"
|
||||
|
||||
# Remove BaseUrl
|
||||
if grep -q "radarr" "$CONFIG_LOCATION"; then
|
||||
if grep -q "$slug" "$CONFIG_LOCATION"; then
|
||||
bashio::log.warning "BaseUrl removed, restarting"
|
||||
sed -i "/radarr/d" "$CONFIG_LOCATION"
|
||||
sed -i "/$slug/d" "$CONFIG_LOCATION"
|
||||
bashio::addon.restart
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user