mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 09:51:02 +01:00
30 lines
965 B
Plaintext
30 lines
965 B
Plaintext
#!/usr/bin/with-contenv bashio
|
|
# shellcheck shell=bash
|
|
# ==============================================================================
|
|
|
|
# Wait for transmission to become available
|
|
bashio::net.wait_for 8989 localhost 900
|
|
|
|
# Set base url
|
|
CONFIG_LOCATION=/config/addons_config/sonarr/config.xml
|
|
if bashio::config.has_value 'CONFIG_LOCATION'; then
|
|
CONFIG_LOCATION="$(bashio::config 'CONFIG_LOCATION')"
|
|
# Modify if it is a base directory
|
|
if [ -f "$CONFIG_LOCATION" ]; then CONFIG_LOCATION="$(dirname $CONFIG_LOCATION)"; fi
|
|
fi
|
|
|
|
while ! [ -f "$CONFIG_LOCATION"/config.xml ];
|
|
do
|
|
echo "Waiting for $CONFIG_LOCATION to be created"
|
|
sleep 1
|
|
done
|
|
if ! grep -q "<UrlBase>/sonarr</UrlBase>" "$CONFIG_LOCATION"; then
|
|
bashio::log.warning "BaseUrl not set properly, restarting"
|
|
sed -i "/UrlBase/d" "$CONFIG_LOCATION"
|
|
sed -i "/<Config>/a <UrlBase>\/sonarr<\/UrlBase>" "$CONFIG_LOCATION"
|
|
bashio::addon.restart
|
|
fi
|
|
|
|
bashio::log.info "Starting NGinx..."
|
|
exec nginx
|