@@ -3,12 +3,12 @@ set -euo pipefail # Exit on error, undefined variables, and pipe failures
33
44# =======================================
55# Script: qBittorrent Cache Mover - Start
6- # Version: 1.3.3
7- # Updated: 20260614
6+ # Version: 1.3.4
7+ # Updated: 20260817
88# =======================================
99
1010# Script version and update check URLs
11- readonly SCRIPT_VERSION=" 1.3.3 "
11+ readonly SCRIPT_VERSION=" 1.3.4 "
1212readonly SCRIPT_RAW_URL=" https://raw.githubusercontent.com/TRaSH-Guides/Guides/refs/heads/master/includes/downloaders/mover-tuning-start.sh"
1313readonly CONFIG_RAW_URL=" https://raw.githubusercontent.com/TRaSH-Guides/Guides/refs/heads/master/includes/downloaders/mover-tuning.cfg"
1414
@@ -96,6 +96,7 @@ get_instance_details() {
9696 INSTANCE_HOST=" ${HOSTS[$index]} "
9797 INSTANCE_USER=" ${USERS[$index]} "
9898 INSTANCE_PASSWORD=" ${PASSWORDS[$index]} "
99+ INSTANCE_API_KEY=" ${API_KEYS[$index]:- } "
99100 INSTANCE_CA_BUNDLE=" ${CA_BUNDLES[$index]:- } "
100101 else
101102 # Legacy format: map index to old variables
@@ -104,12 +105,14 @@ get_instance_details() {
104105 INSTANCE_HOST=" ${QBIT_HOST_1} "
105106 INSTANCE_USER=" ${QBIT_USER_1} "
106107 INSTANCE_PASSWORD=" ${QBIT_PASS_1} "
108+ INSTANCE_API_KEY=" ${QBIT_API_KEY_1:- } "
107109 INSTANCE_CA_BUNDLE=" ${QBIT_CA_BUNDLE_1:- } "
108110 elif [[ $index -eq 1 ]]; then
109111 INSTANCE_NAME=" ${QBIT_NAME_2} "
110112 INSTANCE_HOST=" ${QBIT_HOST_2} "
111113 INSTANCE_USER=" ${QBIT_USER_2} "
112114 INSTANCE_PASSWORD=" ${QBIT_PASS_2} "
115+ INSTANCE_API_KEY=" ${QBIT_API_KEY_2:- } "
113116 INSTANCE_CA_BUNDLE=" ${QBIT_CA_BUNDLE_2:- } "
114117 else
115118 error " Invalid instance index: $index "
@@ -487,6 +490,14 @@ validate_config() {
487490 fi
488491 fi
489492
493+ # API_KEYS array is optional, but if present should match
494+ if [[ -v API_KEYS ]] && [[ ${# API_KEYS[@]} -gt 0 ]]; then
495+ if [[ ${# API_KEYS[@]} -ne ${# HOSTS[@]} ]]; then
496+ notify " Configuration Error" " API_KEYS array length (${# API_KEYS[@]} ) doesn't match HOSTS (${# HOSTS[@]} )"
497+ error " API_KEYS array length doesn't match HOSTS"
498+ fi
499+ fi
500+
490501 # CA_BUNDLES array is optional, but if present should match
491502 if [[ -v CA_BUNDLES ]] && [[ ${# CA_BUNDLES[@]} -gt 0 ]]; then
492503 if [[ ${# CA_BUNDLES[@]} -ne ${# HOSTS[@]} ]]; then
@@ -510,7 +521,7 @@ validate_config() {
510521# PROCESS QBITTORRENT INSTANCE
511522# ================================
512523process_qbit_instance () {
513- local name=" $1 " host=" $2 " user=" $3 " password=" $4 " ca_bundle =" ${5:- } "
524+ local name=" $1 " host=" $2 " user=" $3 " password=" $4 " api_key =" ${5:- } " ca_bundle= " ${6 :- }"
514525
515526 log " Processing $name ..."
516527
@@ -527,23 +538,29 @@ process_qbit_instance() {
527538 return 1
528539 fi
529540
530- local ca_bundle_args=()
541+ local mover_args=(
542+ --pause
543+ --host " $host "
544+ --cache-mount " $CACHE_MOUNT "
545+ --days_from " $DAYS_FROM "
546+ --days_to " $DAYS_TO "
547+ )
548+
549+ if [[ -n " $api_key " ]]; then
550+ mover_args+=(--api-key " $api_key " )
551+ else
552+ mover_args+=(--user " $user " --password " $password " )
553+ fi
554+
531555 if [[ -n " $ca_bundle " ]]; then
532- ca_bundle_args=(--ca-bundle " $ca_bundle " )
533- fi
534-
535- # Run mover script
536- if $python_cmd " $MOVER_SCRIPT " \
537- --pause \
538- --host " $host " \
539- --user " $user " \
540- --password " $password " \
541- --cache-mount " $CACHE_MOUNT " \
542- --days_from " $DAYS_FROM " \
543- --days_to " $DAYS_TO " \
544- " ${ca_bundle_args[@]} " 2>&1 | while IFS= read -r line; do
556+ mover_args+=(--ca-bundle " $ca_bundle " )
557+ fi
558+
559+ if " $python_cmd " " $MOVER_SCRIPT " " ${mover_args[@]} " 2>&1 |
560+ while IFS= read -r line; do
545561 log " $line "
546- done ; then
562+ done
563+ then
547564 log " ✓ Successfully processed $name "
548565 notify " $name " " Paused @ $( date +%H:%M:%S) "
549566 return 0
@@ -606,7 +623,7 @@ main() {
606623 for (( i= 0 ; i< instance_count; i++ )) ; do
607624 get_instance_details " $i "
608625
609- process_qbit_instance " $INSTANCE_NAME " " $INSTANCE_HOST " " $INSTANCE_USER " " $INSTANCE_PASSWORD " " $INSTANCE_CA_BUNDLE " || (( failed_instances++ ))
626+ process_qbit_instance " $INSTANCE_NAME " " $INSTANCE_HOST " " $INSTANCE_USER " " $INSTANCE_PASSWORD " " $INSTANCE_API_KEY " " $ INSTANCE_CA_BUNDLE" || (( failed_instances++ ))
610627 done
611628
612629 # Summary
0 commit comments