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

@@ -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