Browse Source

Modify qBittorrent post-start hook for default credentials (#1134)

main
Nathan Fretz 7 months ago
committed by GitHub
parent
commit
5906697b55
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 36
      qbittorrent/hooks/post-start
  2. 4
      qbittorrent/umbrel-app.yml

36
qbittorrent/hooks/post-start

@ -6,12 +6,11 @@ set -euo pipefail
# 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. # 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. # The app description in the Umbrel app store encourages users to change the default password.
APP_DATA_DIR="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" APP_DATA_DIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")"
QBITTORRENT_CONF_FILE="${APP_DATA_DIR}/data/config/config/qBittorrent.conf" QBITTORRENT_CONF_FILE="${APP_DATA_DIR}/data/config/config/qBittorrent.conf"
echo "Waiting for file (${QBITTORRENT_CONF_FILE}) to exist..." # Wait up to 30 seconds for the qBittorrent.conf file to exist
echo "Waiting up to 30 seconds for qBittorrent.conf file to exist..."
# Wait up to 30 seconds...
for attempt in $(seq 1 300); do for attempt in $(seq 1 300); do
if [[ -f "${QBITTORRENT_CONF_FILE}" ]]; then if [[ -f "${QBITTORRENT_CONF_FILE}" ]]; then
echo "qBittorrent.conf file exists" echo "qBittorrent.conf file exists"
@ -21,27 +20,30 @@ for attempt in $(seq 1 300); do
done done
if [[ ! -f "${QBITTORRENT_CONF_FILE}" ]]; then if [[ ! -f "${QBITTORRENT_CONF_FILE}" ]]; then
echo "qBittorrent.conf was never created. Something is likely wrong with the qBittorrent app." echo "qBittorrent.conf was never created. Something is likely wrong with the qBittorrent app."
exit exit
fi fi
# 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. # 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. # This line is expected to be under the [Preferences] section.
if ! grep --quiet '^WebUI\\Password_PBKDF2' "${QBITTORRENT_CONF_FILE}"; then if ! grep --quiet '^WebUI\\Password_PBKDF2' "${QBITTORRENT_CONF_FILE}"; then
echo "Writing default password adminadmin to qBittorrent.conf" echo "WebUI\\Password_PBKDF2 does not exist in qBittorrent.conf. Adding default password."
# Add the WebUI\Password_PBKDF2 line directly to the qBittorrent.conf file # wait 5 seconds to be extra sure the file is fully written by the qBittorrent service
# This salted hash is for the password 'adminadmin' echo "Waiting 5 seconds for qBittorrent.conf file to be fully written..."
awk '/^\[Preferences\]/ { print; print "WebUI\\Password_PBKDF2=\"@ByteArray(gTzqQHUv3A1X43tLaAhaJQ==:ZBCIBA4honNZ7H66xdEoHpqBC/Vvwj17ZCjQKARSK78ScJWDMdWSfxezHG536UekAL/zpRn571MXCfhtdqiArA==)\""; next }1' "${QBITTORRENT_CONF_FILE}" > "${QBITTORRENT_CONF_FILE}.tmp" sleep 5
# Backup the original configuration file # stop the qBittorrent service
cp "${QBITTORRENT_CONF_FILE}" "${QBITTORRENT_CONF_FILE}.bak" 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}"
# Replace the original configuration file with the updated one # start the qBittorrent service
mv "${QBITTORRENT_CONF_FILE}.tmp" "${QBITTORRENT_CONF_FILE}" echo "Starting qBittorrent..."
"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" start server
echo "Password has been set to 'adminadmin'."
else else
echo "'WebUI\\Password_PBKDF2' already exists in qBittorrent.conf. No changes made." echo "'WebUI\\Password_PBKDF2' already exists in qBittorrent.conf. No changes made."
fi fi

4
qbittorrent/umbrel-app.yml

@ -2,7 +2,7 @@ manifestVersion: 1.1
id: qbittorrent id: qbittorrent
category: networking category: networking
name: qBittorrent name: qBittorrent
version: "4.6.5" version: "4.6.5-hotfix"
tagline: Free and reliable P2P Bittorrent client tagline: Free and reliable P2P Bittorrent client
description: >- 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. 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.
@ -20,7 +20,7 @@ description: >-
⚠️ qBittorrent downloads torrents over the Clearnet, not Tor. ⚠️ qBittorrent downloads torrents over the Clearnet, not Tor.
releaseNotes: >- releaseNotes: >-
This release updates qBittorrent from version 4.6.0 to 4.6.5. 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.
⚠️ 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. ⚠️ 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.

Loading…
Cancel
Save