From 08171bf2fb9824b453b0334b50e062f2055b2deb Mon Sep 17 00:00:00 2001 From: Lucas Serverhost Date: Mon, 9 Nov 2026 20:40:44 +0100 Subject: [PATCH] feat(docker_compose): mediahost nfs, update backup for py,remove old copy torrent_complete scripts --- docker_compose/backup_docker.sh | 7 +- .../config/torrent_qbittorrent_complete.sh | 193 ------------------ .../qbittorrent/docker-compose.yaml | 7 +- .../torrent_qbittorrent_complete.sh | 193 ------------------ .../torrent_qbittorrent_complete.sh | 193 ------------------ 5 files changed, 8 insertions(+), 585 deletions(-) delete mode 100755 docker_compose/serverhost/qbittorrent/config/torrent_qbittorrent_complete.sh delete mode 100755 docker_compose/serverhost/qbittorrent/qbittorrent-private/torrent_qbittorrent_complete.sh delete mode 100755 docker_compose/serverhost/qbittorrent/qbittorrent-public/torrent_qbittorrent_complete.sh diff --git a/docker_compose/backup_docker.sh b/docker_compose/backup_docker.sh index d8e2b06..6cda1b8 100755 --- a/docker_compose/backup_docker.sh +++ b/docker_compose/backup_docker.sh @@ -1,8 +1,5 @@ #!/bin/bash cd /docker -find . -maxdepth 3 -type f \ - \( -name "*.yaml" -o -name "*.yml" -o -name "*.conf" -o -name "*.sh" \) \ - -print0 2>/dev/null | - -rsync -aR --files-from=- --from0 ./ /home/lucas/scripts/docker_compose/$(hostname) +find . -maxdepth 3 -type f \( -name "*.yaml" -o -name "*.yml" -o -name "*.conf" -o -name "*.sh" -o -name "*.py" \) \ + -print0 2>/dev/null | rsync -aR --files-from=- --from0 ./ /home/lucas/scripts/docker_compose/$(hostname) crontab -l > /home/lucas/scripts/docker_compose/$(hostname)/crontab.bak diff --git a/docker_compose/serverhost/qbittorrent/config/torrent_qbittorrent_complete.sh b/docker_compose/serverhost/qbittorrent/config/torrent_qbittorrent_complete.sh deleted file mode 100755 index 63ae9ed..0000000 --- a/docker_compose/serverhost/qbittorrent/config/torrent_qbittorrent_complete.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash - -############################################################################### -# Description: -# qBittorrent external script that: -# 1. Receives torrent name, root path and category from qBittorrent. -# 2. Sends the torrent name to torrent_mqtt.py. -# 3. Copies the torrent contents to mediahost via SCP. -# 4. Logs all output to a timestamped logfile. -# -# Usage: -# torrent_complete.sh -# -# qBittorrent configuration: -# /home/lucas/scripts/serverhost/torrent_complete.sh "%N" "%R" "%L" -# -# Arguments: -# $1 Torrent name -# $2 Root path -# $3 Torrent category -# -# Log files: -# /home/lucas/.LOG/log_torrent_name_YYYY-MM-DD_HH-MM-SS.log -# -# Requirements: -# - bash -# - scp -# - SSH access to "mediahost" -# - /home/lucas/scripts/serverhost/torrent_mqtt.py -############################################################################### - -set -u - -SCRIPT_NAME="$(basename "$0")" - -############################################################################### -# Usage -############################################################################### - -usage() { - cat < - -Description: - Sends the torrent name to torrent_mqtt.py and copies the torrent - contents to mediahost. - -Arguments: - torrent_name Torrent name - root_path Torrent root path - category Torrent category - -Example: - $SCRIPT_NAME "Ubuntu 24.04" "/downloads/Ubuntu 24.04" "Linux" - -qBittorrent: - $SCRIPT_NAME "%N" "%R" "%L" - -EOF -} - -############################################################################### -# Check arguments -############################################################################### - -if [[ $# -ne 3 ]]; then - usage >&2 - exit 1 -fi - -TORRENT_NAME="$1" -ROOT_PATH="$2" -CATEGORY="$3" -if [[ "$CATEGORY" != *arr* && "$CATEGORY" != "mytorrents" ]]; then - - ############################################################################### - # Start - ############################################################################### - - echo "==================================================" - echo "Torrent transfer started" - echo "Date: $(date)" - echo "Script: $SCRIPT_NAME" - echo "Torrent name: $TORRENT_NAME" - echo "Root path: $ROOT_PATH" - echo "Category: $CATEGORY" - echo "==================================================" - - ############################################################################### - # Check for scp command - ############################################################################### - - if ! command -v scp >/dev/null 2>&1; then - echo "Install scp" - sed -i 's|http://|https://|g' /etc/apk/repositories - for i in {1..12}; do - if apk add --no-cache openssh-client; then - break - fi - - echo "Retry $i/12" - sleep 5 - done - fi - - - - ############################################################################### - # Send torrent name to MQTT script - ############################################################################### - - echo - echo "--- Sending torrent name to torrent_mqtt.py ---" - - /config/.venv/bin/python3 /config/torrent_mqtt.py "$TORRENT_NAME" - - MQTT_STATUS=$? - - echo "torrent_mqtt.py exit status: $MQTT_STATUS" - - ############################################################################### - # Check root path - ############################################################################### - - echo - echo "--- Checking root path ---" - - if [[ ! -d "$ROOT_PATH" ]]; then - echo "ERROR: Root path does not exist or is not a directory:" - echo " $ROOT_PATH" - exit 1 - fi - - echo "Root path exists." - - ############################################################################### - # 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 "--- Copying torrent to mediahost ---" - echo "Source: $ROOT_PATH" - echo "Destination: 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/$remote_dir/ - SCP_STATUS=$? - - echo "scp exit status: $SCP_STATUS" - - ############################################################################### - # Result - ############################################################################### - - echo - echo "==================================================" - - if [[ $MQTT_STATUS -ne 0 ]]; then - echo "WARNING: torrent_mqtt.py failed." - 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 - echo "Torrent transfer completed successfully." - else - echo "ERROR: Torrent transfer failed." - fi - - echo "Finished: $(date +'%y%m%d %H%M%Sr')" - echo "==================================================" -else - echo "ARR handled torrent: $(date +'%y%m%d %H%M%S'): $TORRENT_NAME" -fi - -# Return SCP's exit status to qBittorrent -exit 0 - diff --git a/docker_compose/serverhost/qbittorrent/docker-compose.yaml b/docker_compose/serverhost/qbittorrent/docker-compose.yaml index 33924d2..1b1a865 100644 --- a/docker_compose/serverhost/qbittorrent/docker-compose.yaml +++ b/docker_compose/serverhost/qbittorrent/docker-compose.yaml @@ -7,6 +7,7 @@ services: - TZ=Europe/Vienna - PUID=1000 - WEBUI_PORT=8080 + - WEBUI_NAME=qBittorrent-Private ports: - "8080:8080/tcp" - "55661:55661/udp" @@ -15,9 +16,11 @@ services: volumes: - "./10-torrent-init.sh:/custom-cont-init.d/10-torrent-init.sh:ro" - "./qbittorrent-private:/config" + - "./qbittorrent-scripts:/scripts" - "/home/lucas/scripts/torrent:/hostscripts:ro" - "/torrent/qbittorrent-private/downloads:/downloads-private" - "/torrent/qbittorrent-private/torrents:/torrents" + - "/torrent/qbittorrent/mediahost:/mediahost" qbittorrent-public: # image: "lscr.io/linuxserver/qbittorrent:latest" build: qbittorrent-public/ @@ -27,6 +30,7 @@ services: - TZ=Europe/Vienna - PUID=1000 - WEBUI_PORT=8080 + - WEBUI_NAME=qBittorrent-Public network_mode: "service:gluetun" depends_on: - gluetun @@ -38,11 +42,12 @@ services: volumes: - "./10-torrent-init.sh:/custom-cont-init.d/10-torrent-init.sh:ro" - "./qbittorrent-public:/config" + - "./qbittorrent-scripts:/scripts" - "/home/lucas/scripts/torrent:/hostscripts:ro" - "/torrent/qbittorrent-public/downloads:/downloads-public" - - "/torrent/qbittorrent-public/buffer:/downloads-private" - "/torrent/qbittorrent-public/torrents:/torrents" - "/data/torrent:/downloads-special" + - "/torrent/qbittorrent/mediahost:/mediahost" gluetun: image: qmcgaw/gluetun:latest container_name: gluetun diff --git a/docker_compose/serverhost/qbittorrent/qbittorrent-private/torrent_qbittorrent_complete.sh b/docker_compose/serverhost/qbittorrent/qbittorrent-private/torrent_qbittorrent_complete.sh deleted file mode 100755 index 63ae9ed..0000000 --- a/docker_compose/serverhost/qbittorrent/qbittorrent-private/torrent_qbittorrent_complete.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash - -############################################################################### -# Description: -# qBittorrent external script that: -# 1. Receives torrent name, root path and category from qBittorrent. -# 2. Sends the torrent name to torrent_mqtt.py. -# 3. Copies the torrent contents to mediahost via SCP. -# 4. Logs all output to a timestamped logfile. -# -# Usage: -# torrent_complete.sh -# -# qBittorrent configuration: -# /home/lucas/scripts/serverhost/torrent_complete.sh "%N" "%R" "%L" -# -# Arguments: -# $1 Torrent name -# $2 Root path -# $3 Torrent category -# -# Log files: -# /home/lucas/.LOG/log_torrent_name_YYYY-MM-DD_HH-MM-SS.log -# -# Requirements: -# - bash -# - scp -# - SSH access to "mediahost" -# - /home/lucas/scripts/serverhost/torrent_mqtt.py -############################################################################### - -set -u - -SCRIPT_NAME="$(basename "$0")" - -############################################################################### -# Usage -############################################################################### - -usage() { - cat < - -Description: - Sends the torrent name to torrent_mqtt.py and copies the torrent - contents to mediahost. - -Arguments: - torrent_name Torrent name - root_path Torrent root path - category Torrent category - -Example: - $SCRIPT_NAME "Ubuntu 24.04" "/downloads/Ubuntu 24.04" "Linux" - -qBittorrent: - $SCRIPT_NAME "%N" "%R" "%L" - -EOF -} - -############################################################################### -# Check arguments -############################################################################### - -if [[ $# -ne 3 ]]; then - usage >&2 - exit 1 -fi - -TORRENT_NAME="$1" -ROOT_PATH="$2" -CATEGORY="$3" -if [[ "$CATEGORY" != *arr* && "$CATEGORY" != "mytorrents" ]]; then - - ############################################################################### - # Start - ############################################################################### - - echo "==================================================" - echo "Torrent transfer started" - echo "Date: $(date)" - echo "Script: $SCRIPT_NAME" - echo "Torrent name: $TORRENT_NAME" - echo "Root path: $ROOT_PATH" - echo "Category: $CATEGORY" - echo "==================================================" - - ############################################################################### - # Check for scp command - ############################################################################### - - if ! command -v scp >/dev/null 2>&1; then - echo "Install scp" - sed -i 's|http://|https://|g' /etc/apk/repositories - for i in {1..12}; do - if apk add --no-cache openssh-client; then - break - fi - - echo "Retry $i/12" - sleep 5 - done - fi - - - - ############################################################################### - # Send torrent name to MQTT script - ############################################################################### - - echo - echo "--- Sending torrent name to torrent_mqtt.py ---" - - /config/.venv/bin/python3 /config/torrent_mqtt.py "$TORRENT_NAME" - - MQTT_STATUS=$? - - echo "torrent_mqtt.py exit status: $MQTT_STATUS" - - ############################################################################### - # Check root path - ############################################################################### - - echo - echo "--- Checking root path ---" - - if [[ ! -d "$ROOT_PATH" ]]; then - echo "ERROR: Root path does not exist or is not a directory:" - echo " $ROOT_PATH" - exit 1 - fi - - echo "Root path exists." - - ############################################################################### - # 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 "--- Copying torrent to mediahost ---" - echo "Source: $ROOT_PATH" - echo "Destination: 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/$remote_dir/ - SCP_STATUS=$? - - echo "scp exit status: $SCP_STATUS" - - ############################################################################### - # Result - ############################################################################### - - echo - echo "==================================================" - - if [[ $MQTT_STATUS -ne 0 ]]; then - echo "WARNING: torrent_mqtt.py failed." - 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 - echo "Torrent transfer completed successfully." - else - echo "ERROR: Torrent transfer failed." - fi - - echo "Finished: $(date +'%y%m%d %H%M%Sr')" - echo "==================================================" -else - echo "ARR handled torrent: $(date +'%y%m%d %H%M%S'): $TORRENT_NAME" -fi - -# Return SCP's exit status to qBittorrent -exit 0 - diff --git a/docker_compose/serverhost/qbittorrent/qbittorrent-public/torrent_qbittorrent_complete.sh b/docker_compose/serverhost/qbittorrent/qbittorrent-public/torrent_qbittorrent_complete.sh deleted file mode 100755 index 63ae9ed..0000000 --- a/docker_compose/serverhost/qbittorrent/qbittorrent-public/torrent_qbittorrent_complete.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash - -############################################################################### -# Description: -# qBittorrent external script that: -# 1. Receives torrent name, root path and category from qBittorrent. -# 2. Sends the torrent name to torrent_mqtt.py. -# 3. Copies the torrent contents to mediahost via SCP. -# 4. Logs all output to a timestamped logfile. -# -# Usage: -# torrent_complete.sh -# -# qBittorrent configuration: -# /home/lucas/scripts/serverhost/torrent_complete.sh "%N" "%R" "%L" -# -# Arguments: -# $1 Torrent name -# $2 Root path -# $3 Torrent category -# -# Log files: -# /home/lucas/.LOG/log_torrent_name_YYYY-MM-DD_HH-MM-SS.log -# -# Requirements: -# - bash -# - scp -# - SSH access to "mediahost" -# - /home/lucas/scripts/serverhost/torrent_mqtt.py -############################################################################### - -set -u - -SCRIPT_NAME="$(basename "$0")" - -############################################################################### -# Usage -############################################################################### - -usage() { - cat < - -Description: - Sends the torrent name to torrent_mqtt.py and copies the torrent - contents to mediahost. - -Arguments: - torrent_name Torrent name - root_path Torrent root path - category Torrent category - -Example: - $SCRIPT_NAME "Ubuntu 24.04" "/downloads/Ubuntu 24.04" "Linux" - -qBittorrent: - $SCRIPT_NAME "%N" "%R" "%L" - -EOF -} - -############################################################################### -# Check arguments -############################################################################### - -if [[ $# -ne 3 ]]; then - usage >&2 - exit 1 -fi - -TORRENT_NAME="$1" -ROOT_PATH="$2" -CATEGORY="$3" -if [[ "$CATEGORY" != *arr* && "$CATEGORY" != "mytorrents" ]]; then - - ############################################################################### - # Start - ############################################################################### - - echo "==================================================" - echo "Torrent transfer started" - echo "Date: $(date)" - echo "Script: $SCRIPT_NAME" - echo "Torrent name: $TORRENT_NAME" - echo "Root path: $ROOT_PATH" - echo "Category: $CATEGORY" - echo "==================================================" - - ############################################################################### - # Check for scp command - ############################################################################### - - if ! command -v scp >/dev/null 2>&1; then - echo "Install scp" - sed -i 's|http://|https://|g' /etc/apk/repositories - for i in {1..12}; do - if apk add --no-cache openssh-client; then - break - fi - - echo "Retry $i/12" - sleep 5 - done - fi - - - - ############################################################################### - # Send torrent name to MQTT script - ############################################################################### - - echo - echo "--- Sending torrent name to torrent_mqtt.py ---" - - /config/.venv/bin/python3 /config/torrent_mqtt.py "$TORRENT_NAME" - - MQTT_STATUS=$? - - echo "torrent_mqtt.py exit status: $MQTT_STATUS" - - ############################################################################### - # Check root path - ############################################################################### - - echo - echo "--- Checking root path ---" - - if [[ ! -d "$ROOT_PATH" ]]; then - echo "ERROR: Root path does not exist or is not a directory:" - echo " $ROOT_PATH" - exit 1 - fi - - echo "Root path exists." - - ############################################################################### - # 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 "--- Copying torrent to mediahost ---" - echo "Source: $ROOT_PATH" - echo "Destination: 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/$remote_dir/ - SCP_STATUS=$? - - echo "scp exit status: $SCP_STATUS" - - ############################################################################### - # Result - ############################################################################### - - echo - echo "==================================================" - - if [[ $MQTT_STATUS -ne 0 ]]; then - echo "WARNING: torrent_mqtt.py failed." - 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 - echo "Torrent transfer completed successfully." - else - echo "ERROR: Torrent transfer failed." - fi - - echo "Finished: $(date +'%y%m%d %H%M%Sr')" - echo "==================================================" -else - echo "ARR handled torrent: $(date +'%y%m%d %H%M%S'): $TORRENT_NAME" -fi - -# Return SCP's exit status to qBittorrent -exit 0 -