From 46a8d3ebaae7b3ff28bbc97c0eec9b1731205bd8 Mon Sep 17 00:00:00 2001 From: nmfretz Date: Mon, 8 Jul 2024 11:14:11 +1000 Subject: [PATCH] Update SABnzbd --- sabnzbd/docker-compose.yml | 6 +- sabnzbd/hooks/post-install | 131 +++++++++++++++++++++++++++++++++++++ sabnzbd/umbrel-app.yml | 33 ++++------ 3 files changed, 144 insertions(+), 26 deletions(-) create mode 100755 sabnzbd/hooks/post-install diff --git a/sabnzbd/docker-compose.yml b/sabnzbd/docker-compose.yml index 1909dced9..cd981add5 100644 --- a/sabnzbd/docker-compose.yml +++ b/sabnzbd/docker-compose.yml @@ -8,15 +8,11 @@ services: PROXY_AUTH_WHITELIST: "/api*" web: - image: lscr.io/linuxserver/sabnzbd:4.1.0@sha256:84a54b2bd29198bc76e253c8592ac72996737d79f845c1db56ab053739cb61bc + image: lscr.io/linuxserver/sabnzbd:4.3.2@sha256:db76abdcd65ba2c06a630d17d7e71e75245f8c7ace734d4cadd6402e2776ad5c restart: unless-stopped stop_grace_period: 1m volumes: - ${APP_DATA_DIR}/data/config:/config - # sabnzdb offers no way to change the default download directory via environment variables - # and the sabnzbd.ini is not generated until after going through the setup wizard, which automatically sets the download directory to /config/Downloads - # users then need to manually change the download directory to /downloads in Settings > Folders - # This must be done in order to integrate easily properly with other apps like Sonarr and Radarr - ${UMBREL_ROOT}/data/storage/downloads:/downloads environment: - PUID=1000 diff --git a/sabnzbd/hooks/post-install b/sabnzbd/hooks/post-install new file mode 100755 index 000000000..d2560a6c7 --- /dev/null +++ b/sabnzbd/hooks/post-install @@ -0,0 +1,131 @@ +#!/usr/bin/env bash +set -euo pipefail + +# This script does 3 main things: +# 1. Sets the default download and complete directories to /downloads/incomplete and /downloads/complete respectively. +# 2. Sets up the ini file so that *arr apps can automatically configure SABnzbd. +# 3. Restarts any installed *arr apps so that autoconfiguration can take place. + +# Before the setup wizard runs we can add the default categories to the SABnzbd app's ini file without needing to worry about preserving user changes. + +# 1. Add the SABnzbd container name to host_whitelist in the SABnzbd app's ini file: +# host_whitelist = , sabnzbd_web_1 + +# 2. Add the default categories to the SABnzbd app's ini file for each arr app. + +APP_DATA_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")" +SABNZBD_CONF_FILE="${APP_DATA_DIR}/data/config/sabnzbd.ini" + +# Wait up to 30 seconds for the sabnzbd.conf file to exist +echo "Waiting up to 30 seconds for sabnzbd.ini file to exist..." +for attempt in $(seq 1 300); do + if [[ -f "${SABNZBD_CONF_FILE}" ]]; then + echo "sabnzbd.ini file exists" + break + fi + sleep 0.1 +done + +if [[ ! -f "${SABNZBD_CONF_FILE}" ]]; then + echo "sabnzbd.ini was never created. Something is likely wrong with the SABnzbd app." + exit +fi + +# wait 5 seconds to be extra sure the file is fully written by the SABnzbd service +echo "Waiting 5 seconds for sabnzbd.ini file to be fully written..." +sleep 5 + +# stop the SABnzbd service +echo "Stopping SABnzbd..." +"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" stop web + +# Overwrite download directories +echo "Overwriting download_dir and complete_dir in sabnzbd.ini" +sed -i 's/download_dir = Downloads\/incomplete/download_dir = \/downloads\/incomplete/' "${SABNZBD_CONF_FILE}" +sed -i 's/complete_dir = Downloads\/complete/complete_dir = \/downloads\/complete/' "${SABNZBD_CONF_FILE}" + +# Add the SABnzbd container name to host_whitelist in the SABnzbd app's ini file +echo "Adding SABnzbd container name to host_whitelist in sabnzbd.ini" +if grep -q '^host_whitelist =' "${SABNZBD_CONF_FILE}"; then + sed -i 's/^host_whitelist = \(.*\)/host_whitelist = \1 sabnzbd_web_1,/' "${SABNZBD_CONF_FILE}" +else + sed -i '/^\[misc\]/a host_whitelist = sabnzbd_web_1,' "${SABNZBD_CONF_FILE}" +fi + +# Add categories to the SABnzbd app's ini file +# We do this because the *arr apps require exact category names to be present in the SABnzbd app's ini file in order to automatically configure SABnzbd. + +categories_content=$(cat << 'EOF' +[categories] +[[*]] +name = * +order = 0 +pp = 3 +script = None +dir = +newzbin = +priority = 0 +[[movies]] +name = movies +order = 0 +pp = +script = Default +dir = /downloads/movies +newzbin = movies +priority = 0 +[[prowlarr-fallback]] +name = prowlarr-fallback +order = 0 +pp = +script = Default +dir = /downloads +newzbin = +priority = -100 +[[books]] +name = books +order = 0 +pp = +script = Default +dir = /downloads/books +newzbin = books +priority = -100 +[[shows]] +name = shows +order = 0 +pp = +script = Default +dir = /downloads/shows +newzbin = shows +priority = 0 +[[music]] +name = music +order = 0 +pp = +script = Default +dir = /downloads/music +newzbin = music +priority = 0 +EOF +) + +# Append the categories to the ini file +echo "$categories_content" >> "$SABNZBD_CONF_FILE" + +echo "Appended [categories] section with subheaders to $SABNZBD_CONF_FILE" + +# Start the SABnzbd service +echo "Starting SABnzbd..." +"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" start web + +# Restart *arr apps in order to trigger automatic configuration +apps=("radarr" "sonarr" "lidarr" "readarr" "prowlarr") + +installed_apps=$("${UMBREL_ROOT}/scripts/app" ls-installed) + +for app in "${apps[@]}"; do + if echo "$installed_apps" | grep --quiet "$app"; then + # We don't block the script on restarting apps because we want to restart all apps in parallel + # AND we need SABnzbd to be listed as an installed app when the apps restart. + "${UMBREL_ROOT}/scripts/app" restart "$app" & + fi +done \ No newline at end of file diff --git a/sabnzbd/umbrel-app.yml b/sabnzbd/umbrel-app.yml index f829be65a..50bf92781 100644 --- a/sabnzbd/umbrel-app.yml +++ b/sabnzbd/umbrel-app.yml @@ -1,8 +1,8 @@ -manifestVersion: 1 +manifestVersion: 1.1 id: sabnzbd category: networking name: SABnzbd -version: "4.1.0-hotfix1" +version: "4.3.2" tagline: The automated Usenet download tool description: >- SABnzbd makes Usenet as simple and streamlined as possible by automating everything we can. All you have to do is add an .nzb. @@ -13,16 +13,16 @@ description: >- If you want to know more you can head over to our website: https://sabnzbd.org. - 🛠️ SET-UP INSTRUCTIONS 🛠️ + 🛠️ SET-UP INSTRUCTIONS - 1. Set the Downloads Folder: During the quick-start wizard, you'll see default download directories ('/config/Downloads/complete' and '/config/Downloads/incomplete'). You will need to change these to - `downloads/complete` and `downloads/incomplete` as shown in the second gallery image above. You can change these by navigating to Settings > Folders in the SABnzbd app. - These directories are pre-configured to map to the main 'downloads' folder on your Umbrel device and to also work seamlessly with other apps like Sonarr and Radarr. + SABnzbd on umbrelOS is set up to work without any additional configuration needed. It will automatically be connected to dependent apps like Radarr, Sonarr, Lidarr, Readarr, and Prowlarr. Simply install additional media apps from the Umbrel App Store, and everything will work seamlessly together. - 2. Integrating with Other Applications: If you want to integrate SABnzbd with other applications such as Sonarr or Radarr, you'll need to use the IP address of your Umbrel device as the 'Host' and use 9876 as the 'Port'. - You can find the IP address of your Umbrel device by checking your router's admin dashboard or by using an IP scanning tool like Angry IP Scanner. + If you want to modify the default categories that are set up on install, you can do so by navigating to the Categories section in the SABnzbd settings tab. + If you do this, you will need to update the categories in your other apps like Sonarr and Radarr to match the ones you set up in SABnzbd in order for them to work together. + + You can also set up API keys for integration with other apps like Sonarr and Radarr by navigating to the General section in the SABnzbd app. developer: sabnzbd website: https://sabnzbd.org/ dependencies: [] @@ -30,23 +30,14 @@ repo: https://github.com/sabnzbd/sabnzbd support: https://forums.sabnzbd.org/ port: 9876 releaseNotes: >- - This is a hotfix release for SABnzbd 4.1.0 on Umbrel. It makes it easier to configure SABnzbd with apps like Sonarr and Radarr. - - - 🚨 If you are already running SABnzbd 4.1.0 on Umbrel, please update your app and then follow these steps to re-configure your downloads folder path. - You may see errors in the UI when first opening SABnzbd after updating. No data has been lost. This is expected and will be fixed after following these steps. + SABnzbd on umbrelOS now offers automatic configuration for media apps like Radarr, Sonarr, Lidarr, Readarr, and Prowlarr. Simply install your preferred media apps from the Umbrel App Store, and the rest will be handled for you. No manual configuration required! - 1. In the SABnzbd app, navigate to Settings > Folders. + Please update your media apps to the latest versions to take advantage of this feature. If you have previously set up qBittorrent with media apps, this update will not affect your existing settings. + If you have not previously set up SABnzbd with media apps it is recommended that you uninstall and reinstall SABnzbd to take advantage of this feature. - 2. Change the 'Temporary Download Folder' to `downloads/incomplete` and the 'Completed Download Folder' to `downloads/complete`. - - - 3. Click 'Save Changes'. - - - You are now set! + Full release notes for SABnzbd are available at https://github.com/sabnzbd/sabnzbd/releases permissions: - STORAGE_DOWNLOADS gallery: