fix: make sure arr config files exist for Bazarr config

This commit is contained in:
Adrien Poupa 2024-03-09 15:44:34 -05:00
parent 5078d257ec
commit 55db10dddb

View File

@ -4,10 +4,7 @@
function update_arr_config { function update_arr_config {
echo "Updating ${container^} configuration..." echo "Updating ${container^} configuration..."
until [ -f ./"$container"/config.xml ] until [ -f ./"$container"/config.xml ]; do sleep 1; done
do
sleep 1
done
sed -i.bak "s/<UrlBase><\/UrlBase>/<UrlBase>\/$1<\/UrlBase>/" ./"$container"/config.xml && rm ./"$container"/config.xml.bak sed -i.bak "s/<UrlBase><\/UrlBase>/<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>\(.*\)<\/ApiKey>.*/\1/p' ./"$container"/config.xml)"'/' .env && rm .env.bak sed -i.bak 's/^'"${container^^}"'_API_KEY=.*/'"${1^^}"'_API_KEY='"$(sed -n 's/.*<ApiKey>\(.*\)<\/ApiKey>.*/\1/p' ./"$container"/config.xml)"'/' .env && rm .env.bak
echo "Update of ${container^} configuration complete." echo "Update of ${container^} configuration complete."
@ -17,9 +14,7 @@ function update_arr_config {
function update_jellyfin_config { function update_jellyfin_config {
echo "Updating ${container^} configuration..." echo "Updating ${container^} configuration..."
until [ -f ./"$container"/network.xml ]; do until [ -f ./"$container"/network.xml ]; do sleep 1; done
sleep 1
done
sed -i.bak "s/<BaseUrl \/>/<BaseUrl>\/$container<\/BaseUrl>/" ./"$container"/network.xml && rm ./"$container"/network.xml.bak sed -i.bak "s/<BaseUrl \/>/<BaseUrl>\/$container<\/BaseUrl>/" ./"$container"/network.xml && rm ./"$container"/network.xml.bak
echo "Update of ${container^} configuration complete." echo "Update of ${container^} configuration complete."
echo "Restarting ${container^}..." echo "Restarting ${container^}..."
@ -28,14 +23,14 @@ function update_jellyfin_config {
function update_bazarr_config { function update_bazarr_config {
echo "Updating ${container^} configuration..." echo "Updating ${container^} configuration..."
until [ -f ./"$container"/config/config/config.yaml ]; do until [ -f ./"$container"/config/config/config.yaml ]; do sleep 1; done
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/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_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 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>\(.*\)<\/ApiKey>.*/\1/p' ./sonarr/config.xml) SONARR_API_KEY=$(sed -n 's/.*<ApiKey>\(.*\)<\/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 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>\(.*\)<\/ApiKey>.*/\1/p' ./radarr/config.xml) RADARR_API_KEY=$(sed -n 's/.*<ApiKey>\(.*\)<\/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 "/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 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