torrent complete qbittorrent inside docker

This commit is contained in:
lucas committed 2026-10-01 14:07:18 +00:00
1 parent 366c26f581
commit b92bdbea7d
1 file changed
+25 -25
+25 -25
View File
@@ -32,7 +32,6 @@
set -u set -u
SCRIPT_NAME="$(basename "$0")" SCRIPT_NAME="$(basename "$0")"
LOG_DIR="/home/lucas/.LOG"
############################################################################### ###############################################################################
# Usage # Usage
@@ -58,8 +57,6 @@ Example:
qBittorrent: qBittorrent:
$SCRIPT_NAME "%N" "%R" "%L" $SCRIPT_NAME "%N" "%R" "%L"
Log directory:
$LOG_DIR
EOF EOF
} }
@@ -76,17 +73,7 @@ TORRENT_NAME="$1"
ROOT_PATH="$2" ROOT_PATH="$2"
CATEGORY="$3" CATEGORY="$3"
############################################################################### if [[ "$CATEGORY" != *arr* ]]; then
# Logging
###############################################################################
mkdir -p "$LOG_DIR"
LOG_FILE="$LOG_DIR/log_torrent_name_$(date '+%Y-%m-%d_%H-%M-%S').log"
# Redirect all stdout and stderr to the logfile
exec >> "$LOG_FILE" 2>&1
############################################################################### ###############################################################################
# Start # Start
############################################################################### ###############################################################################
@@ -98,7 +85,6 @@ echo "Script: $SCRIPT_NAME"
echo "Torrent name: $TORRENT_NAME" echo "Torrent name: $TORRENT_NAME"
echo "Root path: $ROOT_PATH" echo "Root path: $ROOT_PATH"
echo "Category: $CATEGORY" echo "Category: $CATEGORY"
echo "Log file: $LOG_FILE"
echo "==================================================" echo "=================================================="
############################################################################### ###############################################################################
@@ -108,13 +94,7 @@ echo "=================================================="
echo echo
echo "--- Sending torrent name to torrent_mqtt.py ---" echo "--- Sending torrent name to torrent_mqtt.py ---"
if [[ ! -x "/home/lucas/scripts/serverhost/torrent_mqtt.py" ]]; then /config/.venv/bin/python3 /config/torrent_mqtt.py "$TORRENT_NAME"
echo "WARNING: torrent_mqtt.py is not executable."
echo "Attempting to run it through Python..."
python3 "/home/lucas/scripts/serverhost/torrent_mqtt.py" "$TORRENT_NAME"
else
"/home/lucas/scripts/serverhost/torrent_mqtt.py" "$TORRENT_NAME"
fi
MQTT_STATUS=$? MQTT_STATUS=$?
@@ -139,12 +119,24 @@ echo "Root path exists."
# Copy torrent to mediahost # Copy torrent to mediahost
############################################################################### ###############################################################################
basename_root=$(basename "$ROOT_PATH")
echo $basename_root
if [ "$basename_root" = "downloads" ]; then
remote_dir="$TORRENT_NAME"
else
remote_dir="$basename_root"
fi
echo echo
echo "--- Copying torrent to mediahost ---" echo "--- Copying torrent to mediahost ---"
echo "Source: $ROOT_PATH" echo "Source: $ROOT_PATH"
echo "Destination: mediahost:/torrent/qbittorrent/mediahost/" echo "Destination: mediahost:/torrent/qbittorrent/mediahost/"
scp -r "$ROOT_PATH"/. mediahost:/torrent/qbittorrent/mediahost/ ssh -i /config/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
lucas@mediahost "mkdir -p \"/torrent/qbittorrent/mediahost/$remote_dir\""
SSH_STATUS=$?
scp -i /config/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-r "$ROOT_PATH"/. lucas@mediahost:/torrent/qbittorrent/mediahost/
SCP_STATUS=$? SCP_STATUS=$?
echo "scp exit status: $SCP_STATUS" echo "scp exit status: $SCP_STATUS"
@@ -159,6 +151,11 @@ echo "=================================================="
if [[ $MQTT_STATUS -ne 0 ]]; then if [[ $MQTT_STATUS -ne 0 ]]; then
echo "WARNING: torrent_mqtt.py failed." echo "WARNING: torrent_mqtt.py failed."
fi fi
if [[ $SSH_STATUS -eq 0 ]]; then
echo "Target Dir generated"
else
echo "ERROR: Target dir generation failed."
fi
if [[ $SCP_STATUS -eq 0 ]]; then if [[ $SCP_STATUS -eq 0 ]]; then
echo "Torrent transfer completed successfully." echo "Torrent transfer completed successfully."
@@ -166,9 +163,12 @@ else
echo "ERROR: Torrent transfer failed." echo "ERROR: Torrent transfer failed."
fi fi
echo "Finished: $(date)" echo "Finished: $(date +'%y%m%d %H%M%Sr')"
echo "==================================================" echo "=================================================="
else
echo "ARR handled torrent: $(date +'%y%m%d %H%M%S'): $TORRENT_NAME"
fi
# Return SCP's exit status to qBittorrent # Return SCP's exit status to qBittorrent
exit "$SCP_STATUS" exit 0