From bba4317ddf9696ed6a8fc6e83904524b3aaa38fd Mon Sep 17 00:00:00 2001 From: Andy Burke Date: Thu, 14 Mar 2024 14:14:02 -0700 Subject: [PATCH] fix: make update-config.sh support CONFIG_ROOT --- update-config.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/update-config.sh b/update-config.sh index d88bdc1..1c19b5e 100755 --- a/update-config.sh +++ b/update-config.sh @@ -4,9 +4,9 @@ function update_arr_config { echo "Updating ${container^} configuration..." - until [ -f ./"$container"/config.xml ]; do sleep 1; done - sed -i.bak "s/<\/UrlBase>/\/$1<\/UrlBase>/" ./"$container"/config.xml && rm ./"$container"/config.xml.bak - sed -i.bak 's/^'"${container^^}"'_API_KEY=.*/'"${1^^}"'_API_KEY='"$(sed -n 's/.*\(.*\)<\/ApiKey>.*/\1/p' ./"$container"/config.xml)"'/' .env && rm .env.bak + until [ -f ${CONFIG_ROOT:-.}/"$container"/config.xml ]; do sleep 1; done + sed -i.bak "s/<\/UrlBase>/\/$1<\/UrlBase>/" ${CONFIG_ROOT:-.}/"$container"/config.xml && rm ${CONFIG_ROOT:-.}/"$container"/config.xml.bak + sed -i.bak 's/^'"${container^^}"'_API_KEY=.*/'"${1^^}"'_API_KEY='"$(sed -n 's/.*\(.*\)<\/ApiKey>.*/\1/p' ${CONFIG_ROOT:-.}/"$container"/config.xml)"'/' .env && rm .env.bak echo "Update of ${container^} configuration complete." echo "Restarting ${container^}..." docker compose restart "$container" @@ -14,8 +14,8 @@ function update_arr_config { function update_jellyfin_config { echo "Updating ${container^} configuration..." - until [ -f ./"$container"/network.xml ]; do sleep 1; done - sed -i.bak "s//\/$container<\/BaseUrl>/" ./"$container"/network.xml && rm ./"$container"/network.xml.bak + until [ -f ${CONFIG_ROOT:-.}/"$container"/network.xml ]; do sleep 1; done + sed -i.bak "s//\/$container<\/BaseUrl>/" ${CONFIG_ROOT:-.}/"$container"/network.xml && rm ${CONFIG_ROOT:-.}/"$container"/network.xml.bak echo "Update of ${container^} configuration complete." echo "Restarting ${container^}..." docker compose restart "$container" @@ -23,17 +23,17 @@ function update_jellyfin_config { function update_bazarr_config { echo "Updating ${container^} configuration..." - until [ -f ./"$container"/config/config/config.yaml ]; do sleep 1; done - sed -i.bak "s/base_url: ''/base_url: '\/$container'/" ./"$container"/config/config/config.yaml && rm ./"$container"/config/config/config.yaml.bak - sed -i.bak "s/use_radarr: false/use_radarr: true/" ./"$container"/config/config/config.yaml && rm ./"$container"/config/config/config.yaml.bak - sed -i.bak "s/use_sonarr: false/use_sonarr: true/" ./"$container"/config/config/config.yaml && rm ./"$container"/config/config/config.yaml.bak - until [ -f ./sonarr/config.xml ]; do sleep 1; done - SONARR_API_KEY=$(sed -n 's/.*\(.*\)<\/ApiKey>.*/\1/p' ./sonarr/config.xml) - sed -i.bak "/sonarr:/,/^radarr:/ { s/apikey: .*/apikey: $SONARR_API_KEY/; s/base_url: .*/base_url: \/sonarr/; s/ip: .*/ip: sonarr/ }" "$container"/config/config/config.yaml && rm ./"$container"/config/config/config.yaml.bak - until [ -f ./radarr/config.xml ]; do sleep 1; done - RADARR_API_KEY=$(sed -n 's/.*\(.*\)<\/ApiKey>.*/\1/p' ./radarr/config.xml) - sed -i.bak "/radarr:/,/^sonarr:/ { s/apikey: .*/apikey: $RADARR_API_KEY/; s/base_url: .*/base_url: \/radarr/; s/ip: .*/ip: radarr/ }" "$container"/config/config/config.yaml && rm ./"$container"/config/config/config.yaml.bak - sed -i.bak 's/^'"${container^^}"'_API_KEY=.*/'"${container^^}"'_API_KEY='"$(sed -n 's/.*apikey: \(.*\)*/\1/p' ./"$container"/config/config/config.yaml | head -n 1)"'/' .env && rm .env.bak + until [ -f ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml ]; do sleep 1; done + sed -i.bak "s/base_url: ''/base_url: '\/$container'/" ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml && rm ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml.bak + sed -i.bak "s/use_radarr: false/use_radarr: true/" ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml && rm ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml.bak + sed -i.bak "s/use_sonarr: false/use_sonarr: true/" ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml && rm ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml.bak + until [ -f ${CONFIG_ROOT:-.}/sonarr/config.xml ]; do sleep 1; done + SONARR_API_KEY=$(sed -n 's/.*\(.*\)<\/ApiKey>.*/\1/p' ${CONFIG_ROOT:-.}/sonarr/config.xml) + sed -i.bak "/sonarr:/,/^radarr:/ { s/apikey: .*/apikey: $SONARR_API_KEY/; s/base_url: .*/base_url: \/sonarr/; s/ip: .*/ip: sonarr/ }" ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml && rm ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml.bak + until [ -f ${CONFIG_ROOT:-.}/radarr/config.xml ]; do sleep 1; done + RADARR_API_KEY=$(sed -n 's/.*\(.*\)<\/ApiKey>.*/\1/p' ${CONFIG_ROOT:-.}/radarr/config.xml) + sed -i.bak "/radarr:/,/^sonarr:/ { s/apikey: .*/apikey: $RADARR_API_KEY/; s/base_url: .*/base_url: \/radarr/; s/ip: .*/ip: radarr/ }" ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml && rm ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml.bak + sed -i.bak 's/^'"${container^^}"'_API_KEY=.*/'"${container^^}"'_API_KEY='"$(sed -n 's/.*apikey: \(.*\)*/\1/p' ${CONFIG_ROOT:-.}/"$container"/config/config/config.yaml | head -n 1)"'/' .env && rm .env.bak echo "Update of ${container^} configuration complete." echo "Restarting ${container^}..." docker compose restart "$container"