diff --git a/qbittorrent/hooks/post-start b/qbittorrent/hooks/post-start index 432a48759..3f468cf09 100755 --- a/qbittorrent/hooks/post-start +++ b/qbittorrent/hooks/post-start @@ -1,13 +1,22 @@ #!/usr/bin/env bash set -euo pipefail -# As of v4.6.1, qBittorrent no longer supports a default password and instead prints a temporary password to the logs, which is not ideal for users. -# Users are meant to start qBittorrent, copy the temporary password from the container logs, log in with the temporary password, and then set a new password from the UI. -# This script will set the default password to the legacy 'adminadmin' password if the password is not already set. If a user has already set a password, this script will not overwrite it. -# The app description in the Umbrel app store encourages users to change the default password. +echo "inside qbittorrent/hooks/post-start" + +# This script does 2 main things: +# 1. Sets the default password to 'adminadmin' if it hasn't been set yet. This is done so that users can access qBittorrent after installation without needing to access the qBittorrent container logs to retrieve a temporary password which will reset on restart. +# 2. Enables the AuthSubnetWhitelist option and sets the AuthSubnetWhitelist to the umbrel_main_network Docker network subnet. This is done so that we can autoconfigure other apps like Radarr/Sonarr/etc. + +# We use a file called HAS_BEEN_CONFIGURED to indicate that we've already configured qBittorrent. This way users can modify the qBittorrent.conf file without our script overwriting it. APP_DATA_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")" QBITTORRENT_CONF_FILE="${APP_DATA_DIR}/data/config/config/qBittorrent.conf" +UMBREL_QBITTORRENT_CONFIG_FLAG="${APP_DATA_DIR}/HAS_BEEN_CONFIGURED_BY_UMBREL" + +if [[ -f "${UMBREL_QBITTORRENT_CONFIG_FLAG}" ]]; then + echo "qBittorrent has already been configured." + exit +fi # Wait up to 30 seconds for the qBittorrent.conf file to exist echo "Waiting up to 30 seconds for qBittorrent.conf file to exist..." @@ -24,26 +33,68 @@ if [[ ! -f "${QBITTORRENT_CONF_FILE}" ]]; then exit fi +# wait 5 seconds to be extra sure the file is fully written by the qBittorrent service +echo "Waiting 5 seconds for qBittorrent.conf file to be fully written..." +sleep 5 + +if "${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" stop server; then + echo "qBittorrent stopped successfully." +else + echo "Failed to run stop command because we were sent here from the post-start hook. This is expected behavior. Continuing" +fi + +# As of v4.6.1, qBittorrent no longer supports a default password and instead prints a temporary password to the logs, which is not ideal for users. +# Users are meant to start qBittorrent, copy the temporary password from the container logs, log in with the temporary password, and then set a new password from the UI. +# This script will set the default password to the legacy 'adminadmin' password if the password is not already set. If a user has already set a password, this script will not overwrite it. +# The app description in the Umbrel app store encourages users to change the default password. + # If a line with `WebUI\Password_PBKDF2` does not exist yet in the qBittorrent.conf, then a custom password hasn't been set yet and we write out `adminadmin` as the default password. # This line is expected to be under the [Preferences] section. +# We check for this line first because a user may have a legacy install from before qBittorrent removed the default password. if ! grep --quiet '^WebUI\\Password_PBKDF2' "${QBITTORRENT_CONF_FILE}"; then echo "WebUI\\Password_PBKDF2 does not exist in qBittorrent.conf. Adding default password." - # wait 5 seconds to be extra sure the file is fully written by the qBittorrent service - echo "Waiting 5 seconds for qBittorrent.conf file to be fully written..." - sleep 5 - - # stop the qBittorrent service - echo "Stopping qBittorrent..." - "${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" stop server - echo "Writing default password adminadmin to qBittorrent.conf" sed -i '/^\[Preferences\]/a WebUI\\Password_PBKDF2="@ByteArray(gTzqQHUv3A1X43tLaAhaJQ==:ZBCIBA4honNZ7H66xdEoHpqBC/Vvwj17ZCjQKARSK78ScJWDMdWSfxezHG536UekAL/zpRn571MXCfhtdqiArA==)"' "${QBITTORRENT_CONF_FILE}" - # start the qBittorrent service - echo "Starting qBittorrent..." - "${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" start server - else + # This is a legacy install and the user has already set a password. We don't want to overwrite it. echo "'WebUI\\Password_PBKDF2' already exists in qBittorrent.conf. No changes made." -fi \ No newline at end of file +fi + +# Users can overwrite these settings in the qBittorrent.conf file if they want to change them and this script won't overwrite them. + +# Ensure WebUI\AuthSubnetWhitelist is set correctly +echo "Setting AuthSubnetWhitelist=10.21.0.0/16 in qBittorrent.conf" +if grep -q '^WebUI\\AuthSubnetWhitelist=' "${QBITTORRENT_CONF_FILE}"; then + sed -i 's/^WebUI\\AuthSubnetWhitelist=.*/WebUI\\AuthSubnetWhitelist=10.21.0.0\/16/' "${QBITTORRENT_CONF_FILE}" +else + sed -i '/^\[Preferences\]/a WebUI\\AuthSubnetWhitelist=10.21.0.0/16' "${QBITTORRENT_CONF_FILE}" +fi + +# Ensure WebUI\AuthSubnetWhitelistEnabled is set correctly +echo "Setting WebUI\AuthSubnetWhitelistEnabled=true in qBittorrent.conf" +if grep -q '^WebUI\\AuthSubnetWhitelistEnabled=' "${QBITTORRENT_CONF_FILE}"; then + sed -i 's/^WebUI\\AuthSubnetWhitelistEnabled=.*/WebUI\\AuthSubnetWhitelistEnabled=true/' "${QBITTORRENT_CONF_FILE}" +else + sed -i '/^\[Preferences\]/a WebUI\\AuthSubnetWhitelistEnabled=true' "${QBITTORRENT_CONF_FILE}" +fi + +# Create the UMBREL_QBITTORRENT_CONFIG_FLAG file to indicate that we've configured qBittorrent +touch "${UMBREL_QBITTORRENT_CONFIG_FLAG}" + +# start the qBittorrent service +echo "Starting qBittorrent..." +"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" start server + +# 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 qBittorrent to be listed as an installed app when the apps restart. + "${UMBREL_ROOT}/scripts/app" restart "$app" & + fi +done diff --git a/qbittorrent/umbrel-app.yml b/qbittorrent/umbrel-app.yml index 31547ee0f..22721b1ee 100644 --- a/qbittorrent/umbrel-app.yml +++ b/qbittorrent/umbrel-app.yml @@ -2,7 +2,7 @@ manifestVersion: 1.1 id: qbittorrent category: networking name: qBittorrent -version: "4.6.5-hotfix" +version: "4.6.5-autoconfigure" tagline: Free and reliable P2P Bittorrent client description: >- qBittorrent is an open-source software alternative to µTorrent. It's designed to meet the needs of most users while using as little CPU and memory as possible. @@ -10,23 +10,29 @@ description: >- 🛠️ SET-UP INSTRUCTIONS - - qBittorrent on umbrelOS is configured to work without any additional configuration. Please make sure that you do not change the default download path in the app settings. It should remain set to "/app/qBittorrent/downloads" to ensure that your downloads show up in your main Umbrel downloads folder. - - This app comes bundled with VueTorrent, a sleek user interface that provides an alternative to qBittorrent's default interface. - To enable VueTorrent, simply navigate to tools --> options --> Web UI and select "Use alternative Web UI". + qBittorrent 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. + + + Some additional tips: + + + - Please make sure that you do not change the default download path in the app settings. It should remain set to "/app/qBittorrent/downloads" to ensure that your downloads show up in your main Umbrel downloads folder. - It is recommended to change the default password for the app after installation. + + - This app comes bundled with two alternative Web UI's: VueTorrent and Nightwalker. To enable them, navigate to tools --> options --> Web UI and select "Use alternative Web UI". In the "Files location" field, enter "/app/vuetorrent" for VueTorrent or "/app/nightwalker" for Nightwalker and then click "Save". ⚠️ qBittorrent downloads torrents over the Clearnet, not Tor. releaseNotes: >- - This hotfix release addresses an issue where users who installed qBittorrent v4.6.5 on umbrelOS sometimes needed to restart the app to access the web interface. + qBittorrent 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! - ⚠️ After updating, please ensure that your downloads path in the app is set to the default "/app/qBittorrent/downloads" path. This will make it so that your downloads show up in your main Umbrel downloads folder. + 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. - Read the full release notes at https://www.qbittorrent.org/news#sun-may-26th-2024---qbittorrent-v4.6.5-release + Full release notes for qBittorrent are available at https://www.qbittorrent.org/news#sun-may-26th-2024---qbittorrent-v4.6.5-release developer: qBittorrent website: https://qbittorrent.org/ dependencies: []