diff --git a/kubernetes/apps/qbittorrent/qbittorrent/app/externalsecret.yaml b/kubernetes/apps/qbittorrent/qbittorrent/app/externalsecret.yaml
index 288892c7..614723ed 100644
--- a/kubernetes/apps/qbittorrent/qbittorrent/app/externalsecret.yaml
+++ b/kubernetes/apps/qbittorrent/qbittorrent/app/externalsecret.yaml
@@ -15,6 +15,10 @@ spec:
engineVersion: v2
data:
CROSS_SEED_API_KEY: "{{ .CROSS_SEED_API_KEY }}"
+ PUSHOVER_TOKEN: "{{ .qb_token }}"
+ PUSHOVER_USER_KEY: "{{ .userkey_jahanson }}"
dataFrom:
- extract:
key: cross-seed
+ - extract:
+ key: pushover
diff --git a/kubernetes/apps/qbittorrent/qbittorrent/app/helmrelease.yaml b/kubernetes/apps/qbittorrent/qbittorrent/app/helmrelease.yaml
index 2944087d..04fedb7a 100644
--- a/kubernetes/apps/qbittorrent/qbittorrent/app/helmrelease.yaml
+++ b/kubernetes/apps/qbittorrent/qbittorrent/app/helmrelease.yaml
@@ -29,37 +29,34 @@ spec:
annotations:
configmap.reloader.stakater.com/reload: qbittorrent-scripts
secret.reloader.stakater.com/reload: qbittorrent-secret
- pod:
- securityContext:
- fsGroup: 568
- fsGroupChangePolicy: "OnRootMismatch"
containers:
app:
nameOverride: qbittorrent
image:
- repository: ghcr.io/onedr0p/qbittorrent
- tag: 4.6.7@sha256:5391f94b321d563c3b44136a5e799b7e4e4888926c1c31d3081a1cf3e74a9aec
+ repository: ghcr.io/onedr0p/qbittorrent-beta
+ tag: 5.0.1@sha256:684422cab9fe3cba04812cf4207398bb72aa0f0283c92fddecd833648ac3f7bf
env:
UMASK: "022"
- QBITTORRENT__PORT: &port 80
- QBITTORRENT__BT_PORT: &bittorrentPort 50413
- QBT_Preferences__WebUI__AlternativeUIEnabled: false
- QBT_Preferences__WebUI__AuthSubnetWhitelistEnabled: true
- QBT_Preferences__WebUI__AuthSubnetWhitelist: |-
- 10.244.0.0/16, 10.1.2.0/24
- QBT_Preferences__WebUI__LocalHostAuth: false
+ QBT_WEBUI_PORT: &port 80
+ QBT_TORRENTING_PORT: &bittorrentPort 50413
+ CROSS_SEED_ENABLED: true
CROSS_SEED_HOST: cross-seed.qbittorrent.svc.cluster.local
CROSS_SEED_PORT: 80
CROSS_SEED_SLEEP_INTERVAL: 0
+ PUSHOVER_ENABLED: true
envFrom:
- secretRef:
name: qbittorrent-secret
- resources:
- requests:
- cpu: 49m
- memory: 1024Mi
- limits:
- memory: 24Gi
+ probes:
+ liveness:
+ enabled: true
+ readiness:
+ enabled: true
+ startup:
+ enabled: true
+ spec:
+ failureThreshold: 30
+ periodSeconds: 10
securityContext:
runAsUser: 568
runAsGroup: 568
@@ -69,7 +66,22 @@ spec:
capabilities:
drop:
- ALL
-
+ resources:
+ requests:
+ cpu: 100m
+ memory: 1024Mi
+ limits:
+ memory: 24Gi
+ defaultPodOptions:
+ securityContext:
+ runAsNonRoot: true
+ runAsUser: 568
+ runAsGroup: 568
+ fsGroup: 568
+ fsGroupChangePolicy: OnRootMismatch
+ supplementalGroups: [10000]
+ seccompProfile: { type: RuntimeDefault }
+ terminationGracePeriodSeconds: 300
service:
app:
controller: *app
@@ -107,21 +119,11 @@ spec:
name: qbittorrent-scripts
defaultMode: 0775
globalMounts:
- - path: /scripts/cross-seed.sh
- subPath: cross-seed.sh
- readOnly: true
+ - readOnly: true
media:
type: nfs
- server: 10.1.1.13
+ server: gandalf.jahanson.tech
path: /eru/media
- advancedMounts:
- qbittorrent:
- app:
- - path: /data/nas-media
- qbtun:
- type: hostPath
- hostPath: /dev/net
- advancedMounts:
- qbittorrent:
- gluetun:
- - path: /dev/net
+ globalMounts:
+ - path: /data/nas-media/qb
+ subPath: nas-media/qb
diff --git a/kubernetes/apps/qbittorrent/qbittorrent/app/kustomization.yaml b/kubernetes/apps/qbittorrent/qbittorrent/app/kustomization.yaml
index 0f2d15ca..b2b40f67 100644
--- a/kubernetes/apps/qbittorrent/qbittorrent/app/kustomization.yaml
+++ b/kubernetes/apps/qbittorrent/qbittorrent/app/kustomization.yaml
@@ -9,7 +9,7 @@ resources:
configMapGenerator:
- name: qbittorrent-scripts
files:
- - cross-seed.sh=./resources/cross-seed.sh
+ - post-process.sh=./resources/post-process.sh
generatorOptions:
disableNameSuffixHash: true
annotations:
diff --git a/kubernetes/apps/qbittorrent/qbittorrent/app/resources/cross-seed.sh b/kubernetes/apps/qbittorrent/qbittorrent/app/resources/cross-seed.sh
deleted file mode 100644
index 34fc5bb2..00000000
--- a/kubernetes/apps/qbittorrent/qbittorrent/app/resources/cross-seed.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env bash
-
-export CROSS_SEED_HOST=${CROSS_SEED_HOST:-cross-seed.default.svc.cluster.local}
-export CROSS_SEED_PORT=${CROSS_SEED_PORT:-80}
-export CROSS_SEED_API_KEY=${CROSS_SEED_API_KEY:-unset}
-export CROSS_SEED_SLEEP_INTERVAL=${CROSS_SEED_SLEEP_INTERVAL:-30}
-
-SEARCH_PATH=$1
-
-# Update permissions on the search path
-chmod -R 750 "${SEARCH_PATH}"
-
-# Search for cross-seed
-response=$(
- curl \
- --silent \
- --output /dev/null \
- --write-out "%{http_code}" \
- --request POST \
- --data-urlencode "path=${SEARCH_PATH}" \
- --header "X-Api-Key: ${CROSS_SEED_API_KEY}" \
- "http://${CROSS_SEED_HOST}:${CROSS_SEED_PORT}/api/webhook"
-)
-
-if [[ "${response}" != "204" ]]; then
- printf "Failed to search cross-seed for '%s'\n" "${SEARCH_PATH}"
- exit 1
-fi
-
-printf "Successfully searched cross-seed for '%s'\n" "${SEARCH_PATH}"
-
-sleep "${CROSS_SEED_SLEEP_INTERVAL}"
diff --git a/kubernetes/apps/qbittorrent/qbittorrent/app/resources/post-process.sh b/kubernetes/apps/qbittorrent/qbittorrent/app/resources/post-process.sh
new file mode 100644
index 00000000..03b6904c
--- /dev/null
+++ b/kubernetes/apps/qbittorrent/qbittorrent/app/resources/post-process.sh
@@ -0,0 +1,121 @@
+#!/usr/bin/env bash
+# shellcheck disable=SC2154
+
+set -euo pipefail
+
+# User-defined variables
+CROSS_SEED_ENABLED="${CROSS_SEED_ENABLED:-false}"
+CROSS_SEED_HOST="${CROSS_SEED_HOST:-required}"
+CROSS_SEED_PORT="${CROSS_SEED_PORT:-required}"
+CROSS_SEED_API_KEY="${CROSS_SEED_API_KEY:-required}"
+CROSS_SEED_SLEEP_INTERVAL="${CROSS_SEED_SLEEP_INTERVAL:-30}"
+PUSHOVER_ENABLED="${PUSHOVER_ENABLED:-false}"
+PUSHOVER_USER_KEY="${PUSHOVER_USER_KEY:-required}"
+PUSHOVER_TOKEN="${PUSHOVER_TOKEN:-required}"
+
+# Function to set release variables from SABnzbd
+set_sab_vars() {
+ RELEASE_NAME="${SAB_FILENAME:-}"
+ RELEASE_DIR="${SAB_COMPLETE_DIR:-}"
+ RELEASE_CAT="${SAB_CAT:-}"
+ RELEASE_SIZE="${SAB_BYTES:-}"
+ RELEASE_STATUS="${SAB_PP_STATUS:-}"
+ RELEASE_INDEXER="${SAB_URL:-}"
+ RELEASE_TYPE="NZB"
+}
+
+# Function to set release variables from qBittorrent
+set_qb_vars() {
+ RELEASE_NAME="$1" # %N
+ RELEASE_DIR="$2" # %F
+ RELEASE_CAT="$3" # %L
+ RELEASE_SIZE="$4" # %Z
+ RELEASE_INDEXER="$5" # %T
+ RELEASE_STATUS=0 # Always 0 for qBittorrent
+ RELEASE_TYPE="Torrent"
+}
+
+# Function to send pushover notification
+send_pushover_notification() {
+ local pushover_message status_code json_data
+ printf -v pushover_message \
+ "%s\nCategory: %s\nIndexer: %s\nSize: %s" \
+ "${RELEASE_NAME%.*}" \
+ "${RELEASE_CAT}" \
+ "$(trurl --url "${RELEASE_INDEXER}" --get '{idn:host}')" \
+ "$(numfmt --to iec --format "%8.2f" "${RELEASE_SIZE}")"
+
+ json_data=$(jo \
+ token="${PUSHOVER_TOKEN}" \
+ user="${PUSHOVER_USER_KEY}" \
+ title="${RELEASE_TYPE} Downloaded" \
+ message="${pushover_message}" \
+ priority="-2" \
+ html="1"
+ )
+
+ status_code=$(curl \
+ --silent \
+ --write-out "%{http_code}" \
+ --output /dev/null \
+ --request POST \
+ --header "Content-Type: application/json" \
+ --data-binary "${json_data}" \
+ "https://api.pushover.net/1/messages.json"
+ )
+
+ printf "pushover notification returned with HTTP status code %s and payload: %s\n" \
+ "${status_code}" \
+ "$(echo "${json_data}" | jq --compact-output)" >&2
+}
+
+# Function to search for cross-seed
+search_cross_seed() {
+ local status_code
+ status_code=$(curl \
+ --silent \
+ --output /dev/null \
+ --write-out "%{http_code}" \
+ --request POST \
+ --data-urlencode "path=${RELEASE_DIR}" \
+ --header "X-Api-Key: ${CROSS_SEED_API_KEY}" \
+ "http://${CROSS_SEED_HOST}:${CROSS_SEED_PORT}/api/webhook"
+ )
+
+ printf "cross-seed search returned with HTTP status code %s and path %s\n" \
+ "${status_code}" \
+ "${RELEASE_DIR}" >&2
+
+ sleep "${CROSS_SEED_SLEEP_INTERVAL}"
+}
+
+main() {
+ # Determine the source and set release variables accordingly
+ if env | grep -q "^SAB_"; then
+ set_sab_vars
+ else
+ set_qb_vars "$@"
+ fi
+
+ # Check if post-processing was successful
+ if [[ "${RELEASE_STATUS}" -ne 0 ]]; then
+ printf "post-processing failed with sabnzbd status code %s\n" \
+ "${RELEASE_STATUS}" >&2
+ exit 1
+ fi
+
+ # Update permissions on the release directory
+ chmod -R 750 "${RELEASE_DIR}"
+
+ # Send pushover notification
+ if [[ "${PUSHOVER_ENABLED}" == "true" ]]; then
+ send_pushover_notification
+ fi
+
+ # Search for cross-seed
+ if [[ "${CROSS_SEED_ENABLED}" == "true" ]]; then
+ search_cross_seed
+ fi
+}
+
+main "$@"