Add recyclarr

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-07-10 19:38:19 +01:00
parent 249f6fcac0
commit 3272063a43
17 changed files with 878 additions and 770 deletions

View File

@@ -1,9 +0,0 @@
# shellcheck shell=sh
for filepath in /etc/prowlarr/indexers/*.json; do
curl -sf --retry 10 "$PROWLARR_HOST/api/v1/indexer?forceSave=true" \
-X POST \
-H "Content-Type: application/json" \
-H "X-Api-Key: $PROWLARR_API_KEY" \
--data-binary @"$filepath" || true
done

View File

@@ -1,17 +1,17 @@
# shellcheck shell=sh
# Tag ID: 1
curl -sf "$PROWLARR_HOST/api/v1/tag" \
curl -sf "$HOST/api/v1/tag" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $PROWLARR_API_KEY" \
-H "X-Api-Key: $API_KEY" \
--data-raw '{"label": "flaresolverr"}' || true
{
curl -sf --retry 5 "$PROWLARR_HOST/api/v1/indexerProxy?forceSave=true" \
curl -sf --retry 5 "$HOST/api/v1/indexerProxy?forceSave=true" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $PROWLARR_API_KEY" \
-H "X-Api-Key: $API_KEY" \
--data-binary @- <<EOF
{
"name": "FlareSolverr",
@@ -33,10 +33,10 @@ EOF
} || true
{
curl -sf --retry 5 "$PROWLARR_HOST/api/v1/downloadclient?forceSave=true" \
curl -sf --retry 5 "$HOST/api/v1/downloadclient?forceSave=true" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $PROWLARR_API_KEY" \
-H "X-Api-Key: $API_KEY" \
--data-binary @- <<EOF
{
"enable": true,
@@ -65,9 +65,17 @@ EOF
} || true
for filepath in /etc/prowlarr/apps/*.json; do
curl -sf --retry 5 "$PROWLARR_HOST/api/v1/applications?forceSave=true" \
curl -sf --retry 5 "$HOST/api/v1/applications?forceSave=true" \
-X POST \
-H "Content-Type: application/json" \
-H "X-Api-Key: $PROWLARR_API_KEY" \
-H "X-Api-Key: $API_KEY" \
--data-binary @"$filepath" || true
done
for filepath in /etc/prowlarr/indexers/*.json; do
curl -sf --retry 10 "$HOST/api/v1/indexer?forceSave=true" \
-X POST \
-H "Content-Type: application/json" \
-H "X-Api-Key: $API_KEY" \
--data-binary @"$filepath" || true
done

View File

@@ -1,14 +1,14 @@
# shellcheck shell=sh
RADARR_DOWNLOAD_CATEGORY="${RADARR_DOWNLOAD_CATEGORY:-radarr}"
DOWNLOAD_CATEGORY="${DOWNLOAD_CATEGORY:-radarr}"
mkdir -p "/var/lib/transmission/$RADARR_DOWNLOAD_CATEGORY"
mkdir -p "/var/lib/transmission/$DOWNLOAD_CATEGORY"
{
curl -sf --retry 5 "$RADARR_HOST/api/v3/downloadclient?forceSave=true" \
curl -sf --retry 5 "$HOST/api/v3/downloadclient?forceSave=true" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $RADARR_API_KEY" \
-H "X-Api-Key: $API_KEY" \
--data-binary @- <<EOF
{
"enable": true,
@@ -30,7 +30,7 @@ mkdir -p "/var/lib/transmission/$RADARR_DOWNLOAD_CATEGORY"
},
{
"name": "movieCategory",
"value": "$RADARR_DOWNLOAD_CATEGORY"
"value": "$DOWNLOAD_CATEGORY"
}
],
"implementation": "Transmission",
@@ -39,10 +39,10 @@ mkdir -p "/var/lib/transmission/$RADARR_DOWNLOAD_CATEGORY"
EOF
} || true
if [ ! -z "${RADARR_ROOT_FOLDER:-}" ]; then
curl -sf "$RADARR_HOST/api/v3/rootfolder" \
if [ -n "${ROOT_FOLDER:-}" ]; then
curl -sf "$HOST/api/v3/rootfolder" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $RADARR_API_KEY" \
--data-raw "{\"path\": \"$RADARR_ROOT_FOLDER\"}" || true
-H "X-Api-Key: $API_KEY" \
--data-raw "{\"path\": \"$ROOT_FOLDER\"}" || true
fi

View File

@@ -0,0 +1,55 @@
{ base_url, api_key }:
{
radarr.radarr_anime = {
inherit base_url api_key;
delete_old_custom_formats = true;
replace_existing_custom_formats = true;
include = [
{ template = "radarr-quality-definition-anime"; }
{ template = "radarr-quality-profile-anime"; }
{ template = "radarr-custom-formats-anime"; }
];
custom_formats = [
{
trash_ids = [
"064af5f084a0a24458cc8ecd3220f93f" # Uncensored
];
assign_scores_to = [
{
name = "Remux-1080p - Anime";
score = 10;
}
];
}
{
trash_ids = [
"a5d148168c4506b55cf53984107c396e" # 10bit
];
assign_scores_to = [
{
name = "Remux-1080p - Anime";
score = 10;
}
];
}
{
trash_ids = [
"4a3b087eea2ce012fcc1ce319259a3be" # Anime Dual Audio
];
assign_scores_to = [
{
name = "Remux-1080p - Anime";
score = 10;
}
];
}
];
media_naming = {
folder = "default";
movie = {
rename = true;
standard = "anime";
};
};
};
}

View File

@@ -0,0 +1,74 @@
{ base_url, api_key }:
{
radarr.radarr_uhd = {
inherit base_url api_key;
delete_old_custom_formats = true;
replace_existing_custom_formats = true;
include = [
{ template = "radarr-quality-definition-movie"; }
{ template = "radarr-quality-profile-uhd-bluray-web"; }
{ template = "radarr-custom-formats-uhd-bluray-web"; }
];
custom_formats = [
{
trash_ids = [
"570bc9ebecd92723d2d21500f4be314c" # Remaster
"eca37840c13c6ef2dd0262b141a5482f" # 4K Remaster
"e0c07d59beb37348e975a930d5e50319" # Criterion Collection
"9d27d9d2181838f76dee150882bdc58c" # Masters of Cinema
"db9b4c4b53d312a3ca5f1378f6440fc9" # Vinegar Syndrome
"957d0f44b592285f26449575e8b1167e" # Special Edition
"eecf3a857724171f968a66cb5719e152" # IMAX
"9f6cbff8cfe4ebbc1bde14c7b7bec0de" # IMAX Enhanced
];
assign_scores_to = [ { name = "UHD Bluray + WEB"; } ];
}
{
trash_ids = [
"b6832f586342ef70d9c128d40c07b872" # Bad Dual Groups
"cc444569854e9de0b084ab2b8b1532b2" # Black and White Editions
"ae9b7c9ebde1f3bd336a8cbd1ec4c5e5" # No-RlsGroup
];
assign_scores_to = [ { name = "UHD Bluray + WEB"; } ];
}
{
trash_ids = [
"dc98083864ea246d05a42df0d05f81cc" # x265 (HD)
];
assign_scores_to = [
{
name = "UHD Bluray + WEB";
score = 0;
}
];
}
{
trash_ids = [
"839bea857ed2c0a8e084f3cbdbd65ecb" # x265 (no HDR/DV)
];
assign_scores_to = [ { name = "UHD Bluray + WEB"; } ];
}
{
trash_ids = [
"923b6abef9b17f937fab56cfcf89e1f1" # DV (WEBDL)
"b17886cb4158d9fea189859409975758" # HDR10Plus Boost
"55a5b50cb416dea5a50c4955896217ab" # DV HDR10+ Boost
];
assign_scores_to = [ { name = "UHD Bluray + WEB"; } ];
}
{
trash_ids = [
"9c38ebb7384dada637be8899efa68e6f" # SDR
];
assign_scores_to = [ { name = "UHD Bluray + WEB"; } ];
}
];
media_naming = {
folder = "default";
movie = {
rename = true;
standard = "default";
};
};
};
}

View File

@@ -0,0 +1,43 @@
{ base_url, api_key }:
{
radarr.radarr = {
inherit base_url api_key;
delete_old_custom_formats = true;
replace_existing_custom_formats = true;
include = [
{ template = "radarr-quality-definition-movie"; }
{ template = "radarr-quality-profile-hd-bluray-web"; }
{ template = "radarr-custom-formats-hd-bluray-web"; }
];
custom_formats = [
{
trash_ids = [
"570bc9ebecd92723d2d21500f4be314c" # Remaster
"eca37840c13c6ef2dd0262b141a5482f" # 4K Remaster
"e0c07d59beb37348e975a930d5e50319" # Criterion Collection
"9d27d9d2181838f76dee150882bdc58c" # Masters of Cinema
"db9b4c4b53d312a3ca5f1378f6440fc9" # Vinegar Syndrome
"957d0f44b592285f26449575e8b1167e" # Special Edition
"eecf3a857724171f968a66cb5719e152" # IMAX
"9f6cbff8cfe4ebbc1bde14c7b7bec0de" # IMAX Enhanced
];
assign_scores_to = [ { name = "HD Bluray + WEB"; } ];
}
{
trash_ids = [
"b6832f586342ef70d9c128d40c07b872" # Bad Dual Groups
"cc444569854e9de0b084ab2b8b1532b2" # Black and White Editions
"ae9b7c9ebde1f3bd336a8cbd1ec4c5e5" # No-RlsGroup
];
assign_scores_to = [ { name = "HD Bluray + WEB"; } ];
}
];
media_naming = {
folder = "default";
movie = {
rename = true;
standard = "default";
};
};
};
}

View File

@@ -0,0 +1,58 @@
{ base_url, api_key }:
{
sonarr.sonarr_anime = {
inherit base_url api_key;
delete_old_custom_formats = true;
replace_existing_custom_formats = true;
include = [
{ template = "sonarr-quality-definition-anime"; }
{ template = "sonarr-v4-quality-profile-anime"; }
{ template = "sonarr-v4-custom-formats-anime"; }
];
custom_formats = [
{
trash_ids = [
"026d5aadd1a6b4e550b134cb6c72b3ca" # Uncensored
];
assign_scores_to = [
{
name = "Remux-1080p - Anime";
score = 10;
}
];
}
{
trash_ids = [
"b2550eb333d27b75833e25b8c2557b38" # 10bit
];
assign_scores_to = [
{
name = "Remux-1080p - Anime";
score = 10;
}
];
}
{
trash_ids = [
"418f50b10f1907201b6cfdf881f467b7" # Anime Dual Audio
];
assign_scores_to = [
{
name = "Remux-1080p - Anime";
score = 10;
}
];
}
];
media_naming = {
series = "default";
season = "default";
episodes = {
rename = true;
standard = "default";
daily = "default";
anime = "default";
};
};
};
}

View File

@@ -0,0 +1,63 @@
{ base_url, api_key }:
{
sonarr.sonarr_uhd = {
inherit base_url api_key;
delete_old_custom_formats = true;
replace_existing_custom_formats = true;
include = [
{ template = "sonarr-quality-definition-series"; }
{ template = "sonarr-v4-quality-profile-web-2160p"; }
{ template = "sonarr-v4-custom-formats-web-2160p"; }
];
custom_formats = [
{
trash_ids = [
"9b27ab6498ec0f31a3353992e19434ca" # DV (WEBDL)
"0dad0a507451acddd754fe6dc3a7f5e7" # HDR10+ Boost
"385e9e8581d33133c3961bdcdeffb7b4" # DV HDR10+ Boost
];
assign_scores_to = [ { name = "WEB-2160p"; } ];
}
{
trash_ids = [
"32b367365729d530ca1c124a0b180c64" # Bad Dual Groups
"82d40da2bc6923f41e14394075dd4b03" # No-RlsGroup
];
assign_scores_to = [ { name = "WEB-2160p"; } ];
}
{
trash_ids = [
"47435ece6b99a0b477caf360e79ba0bb" # x265 (HD)
];
assign_scores_to = [
{
name = "WEB-2160p";
score = 0;
}
];
}
{
trash_ids = [
"9b64dff695c2115facf1b6ea59c9bd07" # x265 (no HDR/DV)
];
assign_scores_to = [ { name = "WEB-2160p"; } ];
}
{
trash_ids = [
"2016d1676f5ee13a5b7257ff86ac9a93" # SDR
];
assign_scores_to = [ { name = "WEB-2160p"; } ];
}
];
media_naming = {
series = "default";
season = "default";
episodes = {
rename = true;
standard = "default";
daily = "default";
anime = "default";
};
};
};
}

View File

@@ -0,0 +1,49 @@
{ base_url, api_key }:
{
sonarr.sonarr = {
inherit base_url api_key;
delete_old_custom_formats = true;
replace_existing_custom_formats = true;
include = [
{ template = "sonarr-quality-definition-series"; }
{ template = "sonarr-v4-quality-profile-web-1080p"; }
{ template = "sonarr-v4-custom-formats-web-1080p"; }
];
custom_formats = [
{
trash_ids = [
"32b367365729d530ca1c124a0b180c64" # Bad Dual Groups
"82d40da2bc6923f41e14394075dd4b03" # No-RlsGroup
];
assign_scores_to = [ { name = "WEB-1080p"; } ];
}
{
trash_ids = [
"47435ece6b99a0b477caf360e79ba0bb" # x265 (HD)
];
assign_scores_to = [
{
name = "WEB-1080p";
score = 0;
}
];
}
{
trash_ids = [
"9b64dff695c2115facf1b6ea59c9bd07" # x265 (no HDR/DV)
];
assign_scores_to = [ { name = "WEB-1080p"; } ];
}
];
media_naming = {
series = "default";
season = "default";
episodes = {
rename = true;
standard = "default";
daily = "default";
anime = "default";
};
};
};
}

View File

@@ -1,14 +1,14 @@
# shellcheck shell=sh
SONARR_DOWNLOAD_CATEGORY="${SONARR_DOWNLOAD_CATEGORY:-sonarr}"
DOWNLOAD_CATEGORY="${DOWNLOAD_CATEGORY:-sonarr}"
mkdir -p "/var/lib/transmission/$SONARR_DOWNLOAD_CATEGORY"
mkdir -p "/var/lib/transmission/$DOWNLOAD_CATEGORY"
{
curl -sf --retry 10 "$SONARR_HOST/api/v3/downloadclient?forceSave=true" \
curl -sf --retry 10 "$HOST/api/v3/downloadclient?forceSave=true" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $SONARR_API_KEY" \
-H "X-Api-Key: $API_KEY" \
--data-binary @- <<EOF
{
"enable": true,
@@ -30,7 +30,7 @@ mkdir -p "/var/lib/transmission/$SONARR_DOWNLOAD_CATEGORY"
},
{
"name": "tvCategory",
"value": "$SONARR_DOWNLOAD_CATEGORY"
"value": "$DOWNLOAD_CATEGORY"
}
],
"implementation": "Transmission",
@@ -39,10 +39,10 @@ mkdir -p "/var/lib/transmission/$SONARR_DOWNLOAD_CATEGORY"
EOF
} || true
if [ ! -z "${SONARR_ROOT_FOLDER:-}" ]; then
curl -sf "$SONARR_HOST/api/v3/rootfolder" \
if [ -n "${ROOT_FOLDER:-}" ]; then
curl -sf "$HOST/api/v3/rootfolder" \
-X POST \
-H 'Content-Type: application/json' \
-H "X-Api-Key: $SONARR_API_KEY" \
--data-raw "{\"path\": \"$SONARR_ROOT_FOLDER\"}" || true
-H "X-Api-Key: $API_KEY" \
--data-raw "{\"path\": \"$ROOT_FOLDER\"}" || true
fi

View File

@@ -36,6 +36,7 @@
};
docker-prowlarr = import ./docker/prowlarr { inherit pkgs; };
docker-radarr = import ./docker/radarr { inherit pkgs; };
docker-recyclarr = import ./docker/recyclarr { inherit pkgs; };
docker-redis = import ./docker/redis { inherit pkgs; };
docker-shlink = import ./docker/shlink { inherit pkgs inputs system; };
docker-shlink-web-client = import ./docker/shlink-web-client { inherit pkgs inputs system; };

View File

@@ -3,44 +3,46 @@
set -o errexit
set -o nounset
PROWLARR_URL_BASE="${PROWLARR_URL_BASE:-}"
URL_BASE="${URL_BASE:-}"
if [ ! -f /var/lib/prowlarr/init ]; then
if [ ! -f /var/lib/prowlarr/config.xml ]; then
echo '<Config/>' > /var/lib/prowlarr/config.xml
xmlstarlet ed -L \
-s /Config -t elem -n LaunchBrowser -v "False" \
-s /Config -t elem -n ApiKey -v "$PROWLARR_API_KEY" \
-s /Config -t elem -n AuthenticationMethod -v "External" \
-s /Config -t elem -n AuthenticationRequired -v "DisabledForLocalAddresses" \
-s /Config -t elem -n LogLevel -v "info" \
-s /Config -t elem -n UrlBase -v "$PROWLARR_URL_BASE" \
-s /Config -t elem -n InstanceName -v "${PROWLARR_INSTANCE_NAME:-prowlarr}" \
-s /Config -t elem -n AnalyticsEnabled -v "False" \
/var/lib/prowlarr/config.xml
fi
set_config_value() {
name="$1"
value="$2"
CONFIG_FILE="/var/lib/prowlarr/config.xml"
if xmlstarlet sel -t -v "/Config/$name" "$CONFIG_FILE" >/dev/null 2>&1; then
xmlstarlet ed -L -u "/Config/$name" -v "$value" "$CONFIG_FILE"
else
xmlstarlet ed -L -s "/Config" -t elem -n "$name" -v "$value" "$CONFIG_FILE"
fi
}
set_config_value "LaunchBrowser" "False"
set_config_value "ApiKey" "$API_KEY"
set_config_value "AuthenticationMethod" "External"
set_config_value "AuthenticationRequired" "DisabledForLocalAddresses"
set_config_value "LogLevel" "info"
set_config_value "UrlBase" "$URL_BASE"
set_config_value "InstanceName" "${INSTANCE_NAME:-Prowlarr}"
set_config_value "AnalyticsEnabled" "False"
Prowlarr -data=/var/lib/prowlarr -nobrowser "$@" &
PID=$!
PROWLARR_HOST="http://localhost:9696$PROWLARR_URL_BASE"
HOST="http://localhost:9696$URL_BASE"
if [ ! -f /var/lib/prowlarr/init ]; then
curl -sf --retry 10 --retry-connrefused \
-H "X-Api-Key: $PROWLARR_API_KEY" \
"$PROWLARR_HOST/api/v1/health"
curl -sf --retry 10 --retry-connrefused \
-H "X-Api-Key: $API_KEY" \
"$HOST/api/v1/health"
if [ -f /etc/prowlarr/setup.sh ]; then
# shellcheck disable=SC1091
. /etc/prowlarr/setup.sh
fi
touch /var/lib/prowlarr/init
fi
if [ -f /etc/prowlarr/post-start.sh ]; then
if [ -f /etc/prowlarr/setup.sh ]; then
# shellcheck disable=SC1091
. /etc/prowlarr/post-start.sh
. /etc/prowlarr/setup.sh
fi
trap 'kill -INT "$PID"' INT TERM

View File

@@ -3,39 +3,46 @@
set -o errexit
set -o nounset
RADARR_URL_BASE="${RADARR_URL_BASE:-}"
URL_BASE="${URL_BASE:-}"
if [ ! -f /var/lib/radarr/init ]; then
if [ ! -f /var/lib/radarr/config.xml ]; then
echo '<Config/>' > /var/lib/radarr/config.xml
xmlstarlet ed -L \
-s /Config -t elem -n LaunchBrowser -v "False" \
-s /Config -t elem -n ApiKey -v "$RADARR_API_KEY" \
-s /Config -t elem -n AuthenticationMethod -v "External" \
-s /Config -t elem -n AuthenticationRequired -v "DisabledForLocalAddresses" \
-s /Config -t elem -n LogLevel -v "info" \
-s /Config -t elem -n UrlBase -v "$RADARR_URL_BASE" \
-s /Config -t elem -n InstanceName -v "${RADARR_INSTANCE_NAME:-Radarr}" \
-s /Config -t elem -n AnalyticsEnabled -v "False" \
/var/lib/radarr/config.xml
fi
set_config_value() {
name="$1"
value="$2"
CONFIG_FILE="/var/lib/radarr/config.xml"
if xmlstarlet sel -t -v "/Config/$name" "$CONFIG_FILE" >/dev/null 2>&1; then
xmlstarlet ed -L -u "/Config/$name" -v "$value" "$CONFIG_FILE"
else
xmlstarlet ed -L -s "/Config" -t elem -n "$name" -v "$value" "$CONFIG_FILE"
fi
}
set_config_value "LaunchBrowser" "False"
set_config_value "ApiKey" "$API_KEY"
set_config_value "AuthenticationMethod" "External"
set_config_value "AuthenticationRequired" "DisabledForLocalAddresses"
set_config_value "LogLevel" "info"
set_config_value "UrlBase" "$URL_BASE"
set_config_value "InstanceName" "${INSTANCE_NAME:-Radarr}"
set_config_value "AnalyticsEnabled" "False"
Radarr -data=/var/lib/radarr -nobrowser "$@" &
PID=$!
RADARR_HOST="http://localhost:7878$RADARR_URL_BASE"
HOST="http://localhost:7878$URL_BASE"
if [ ! -f /var/lib/radarr/init ]; then
curl -sf --retry 10 --retry-connrefused \
-H "X-Api-Key: $RADARR_API_KEY" \
"$RADARR_HOST/api/v1/health"
curl -sf --retry 10 --retry-connrefused \
-H "X-Api-Key: $API_KEY" \
"$HOST/api/v1/health"
if [ -f /etc/radarr/setup.sh ]; then
# shellcheck disable=SC1091
. /etc/radarr/setup.sh
fi
touch /var/lib/radarr/init
if [ -f /etc/radarr/setup.sh ]; then
# shellcheck disable=SC1091
. /etc/radarr/setup.sh
fi
trap 'kill -INT "$PID"' INT TERM

View File

@@ -0,0 +1,46 @@
{ pkgs, ... }:
let
entrypoint = pkgs.writeTextFile {
name = "entrypoint";
executable = true;
destination = "/bin/entrypoint";
text = builtins.readFile ./entrypoint.sh;
};
crontab = pkgs.writeTextDir "/var/cron/tabs/root" ''
*/0 * * * * recyclarr sync
'';
in
pkgs.dockerTools.buildImage {
name = "recyclarr";
fromImage = import ../base { inherit pkgs; };
copyToRoot = pkgs.buildEnv {
name = "root";
paths = with pkgs; [
entrypoint
crontab
recyclarr
cron
];
pathsToLink = [
"/bin"
"/lib"
"/var"
];
};
runAsRoot = ''
${pkgs.dockerTools.shadowSetup}
mkdir -p /var/run
'';
config = {
Entrypoint = [ "entrypoint" ];
Env = [ "RECYCLARR_APP_DATA=/var/lib/recyclarr" ];
WorkingDir = "/var/lib/recyclarr";
Volumes = {
"/var/lib/recyclarr" = { };
};
};
}

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env sh
set -o errexit
set -o nounset
recyclarr sync
cron
trap : TERM INT; sleep infinity & wait

View File

@@ -3,39 +3,46 @@
set -o errexit
set -o nounset
SONARR_URL_BASE="${SONARR_URL_BASE:-}"
URL_BASE="${URL_BASE:-}"
if [ ! -f /var/lib/sonarr/init ]; then
if [ ! -f /var/lib/sonarr/config.xml ]; then
echo '<Config/>' > /var/lib/sonarr/config.xml
xmlstarlet ed -L \
-s /Config -t elem -n LaunchBrowser -v "False" \
-s /Config -t elem -n ApiKey -v "$SONARR_API_KEY" \
-s /Config -t elem -n AuthenticationMethod -v "External" \
-s /Config -t elem -n AuthenticationRequired -v "DisabledForLocalAddresses" \
-s /Config -t elem -n LogLevel -v "info" \
-s /Config -t elem -n UrlBase -v "$SONARR_URL_BASE" \
-s /Config -t elem -n InstanceName -v "${SONARR_INSTANCE_NAME:-Sonarr}" \
-s /Config -t elem -n AnalyticsEnabled -v "False" \
/var/lib/sonarr/config.xml
fi
set_config_value() {
name="$1"
value="$2"
CONFIG_FILE="/var/lib/sonarr/config.xml"
if xmlstarlet sel -t -v "/Config/$name" "$CONFIG_FILE" >/dev/null 2>&1; then
xmlstarlet ed -L -u "/Config/$name" -v "$value" "$CONFIG_FILE"
else
xmlstarlet ed -L -s "/Config" -t elem -n "$name" -v "$value" "$CONFIG_FILE"
fi
}
set_config_value "LaunchBrowser" "False"
set_config_value "ApiKey" "$API_KEY"
set_config_value "AuthenticationMethod" "External"
set_config_value "AuthenticationRequired" "DisabledForLocalAddresses"
set_config_value "LogLevel" "info"
set_config_value "UrlBase" "$URL_BASE"
set_config_value "InstanceName" "${INSTANCE_NAME:-Sonarr}"
set_config_value "AnalyticsEnabled" "False"
Sonarr -data=/var/lib/sonarr -nobrowser "$@" &
PID=$!
SONARR_HOST="http://localhost:8989$SONARR_URL_BASE"
HOST="http://localhost:8989$URL_BASE"
if [ ! -f /var/lib/sonarr/init ]; then
curl -sf --retry 10 --retry-connrefused \
-H "X-Api-Key: $SONARR_API_KEY" \
"$SONARR_HOST/api/v1/health"
curl -sf --retry 10 --retry-connrefused \
-H "X-Api-Key: $API_KEY" \
"$HOST/api/v1/health"
if [ -f /etc/sonarr/setup.sh ]; then
# shellcheck disable=SC1091
. /etc/sonarr/setup.sh
fi
touch /var/lib/sonarr/init
if [ -f /etc/sonarr/setup.sh ]; then
# shellcheck disable=SC1091
. /etc/sonarr/setup.sh
fi
trap 'kill -INT "$PID"' INT TERM