From b789ac12edfbc8b31ea976a55fc42f41a09492f3 Mon Sep 17 00:00:00 2001 From: Michael Thomson Date: Wed, 27 Nov 2024 11:32:58 -0500 Subject: [PATCH] qbittorrent custom port forward script --- media/qbittorrent/deployment.yaml | 7 +++++++ media/qbittorrent/natpmp-script.yaml | 25 +++++++++++++++++++++++++ media/qbittorrent/wireguard-config.yaml | 6 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 media/qbittorrent/natpmp-script.yaml diff --git a/media/qbittorrent/deployment.yaml b/media/qbittorrent/deployment.yaml index 97db8fa..86ac2a7 100644 --- a/media/qbittorrent/deployment.yaml +++ b/media/qbittorrent/deployment.yaml @@ -47,6 +47,10 @@ spec: mountPath: /config/wg_confs - name: wireguard-config mountPath: /config + - name: natpmp-script + mountPath: /custom-services.d/natpmp.sh + subPath: natpmp.sh + readOnly: true volumes: - name: qbittorrent-config persistentVolumeClaim: @@ -60,3 +64,6 @@ spec: - name: wireguard-config-secret secret: secretName: wireguard-config-secret + - name: natpmp-script + configMap: + name: natpmp-script diff --git a/media/qbittorrent/natpmp-script.yaml b/media/qbittorrent/natpmp-script.yaml new file mode 100644 index 0000000..697fe55 --- /dev/null +++ b/media/qbittorrent/natpmp-script.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +data: + natpmp.sh: | + #!/bin/sh + + while true; do + date + + # Run natpmpc for UDP and TCP, redirect output to a temporary file + natpmpc -a 1 0 udp 60 -g 10.2.0.1 && natpmpc -a 1 0 tcp 60 -g 10.2.0.1 > /tmp/natpmpc_output || { + echo -e "ERROR with natpmpc command \a" + break + } + + # Extract the port numbers from the output and save them in variables + port=$(grep 'TCP' /tmp/natpmpc_output | grep -o 'Mapped public port [0-9]*' | awk '{print $4}') + + echo "Opened port: $port" + sleep 45 + done +kind: ConfigMap +metadata: + creationTimestamp: null + name: natpmp-script + namespace: media diff --git a/media/qbittorrent/wireguard-config.yaml b/media/qbittorrent/wireguard-config.yaml index fa15705..e3f0a08 100644 --- a/media/qbittorrent/wireguard-config.yaml +++ b/media/qbittorrent/wireguard-config.yaml @@ -7,6 +7,6 @@ data: PUID: "1000" GUID: "1000" TZ: America/Toronto - DOCKER_MODS: ghcr.io/fusetim/external_natpmp_qbittorrent:ecf567b21e5f079762e36c9cee9afaf86fcb22be - # DOCKER_MODS: linuxserver/mods:universal-package-install - # INSTALL_PACKAGES: libnatpmp + DOCKER_MODS: linuxserver/mods:universal-package-install + INSTALL_PACKAGES: libnatpmp + # DOCKER_MODS: ghcr.io/fusetim/external_natpmp_qbittorrent:ecf567b21e5f079762e36c9cee9afaf86fcb22be