update to qb5 and add post-process script
This commit is contained in:
parent
55268dfc2c
commit
8d327dcf0c
5 changed files with 163 additions and 68 deletions
|
@ -15,6 +15,10 @@ spec:
|
||||||
engineVersion: v2
|
engineVersion: v2
|
||||||
data:
|
data:
|
||||||
CROSS_SEED_API_KEY: "{{ .CROSS_SEED_API_KEY }}"
|
CROSS_SEED_API_KEY: "{{ .CROSS_SEED_API_KEY }}"
|
||||||
|
PUSHOVER_TOKEN: "{{ .qb_token }}"
|
||||||
|
PUSHOVER_USER_KEY: "{{ .userkey_jahanson }}"
|
||||||
dataFrom:
|
dataFrom:
|
||||||
- extract:
|
- extract:
|
||||||
key: cross-seed
|
key: cross-seed
|
||||||
|
- extract:
|
||||||
|
key: pushover
|
||||||
|
|
|
@ -29,37 +29,34 @@ spec:
|
||||||
annotations:
|
annotations:
|
||||||
configmap.reloader.stakater.com/reload: qbittorrent-scripts
|
configmap.reloader.stakater.com/reload: qbittorrent-scripts
|
||||||
secret.reloader.stakater.com/reload: qbittorrent-secret
|
secret.reloader.stakater.com/reload: qbittorrent-secret
|
||||||
pod:
|
|
||||||
securityContext:
|
|
||||||
fsGroup: 568
|
|
||||||
fsGroupChangePolicy: "OnRootMismatch"
|
|
||||||
containers:
|
containers:
|
||||||
app:
|
app:
|
||||||
nameOverride: qbittorrent
|
nameOverride: qbittorrent
|
||||||
image:
|
image:
|
||||||
repository: ghcr.io/onedr0p/qbittorrent
|
repository: ghcr.io/onedr0p/qbittorrent-beta
|
||||||
tag: 4.6.7@sha256:5391f94b321d563c3b44136a5e799b7e4e4888926c1c31d3081a1cf3e74a9aec
|
tag: 5.0.1@sha256:684422cab9fe3cba04812cf4207398bb72aa0f0283c92fddecd833648ac3f7bf
|
||||||
env:
|
env:
|
||||||
UMASK: "022"
|
UMASK: "022"
|
||||||
QBITTORRENT__PORT: &port 80
|
QBT_WEBUI_PORT: &port 80
|
||||||
QBITTORRENT__BT_PORT: &bittorrentPort 50413
|
QBT_TORRENTING_PORT: &bittorrentPort 50413
|
||||||
QBT_Preferences__WebUI__AlternativeUIEnabled: false
|
CROSS_SEED_ENABLED: true
|
||||||
QBT_Preferences__WebUI__AuthSubnetWhitelistEnabled: true
|
|
||||||
QBT_Preferences__WebUI__AuthSubnetWhitelist: |-
|
|
||||||
10.244.0.0/16, 10.1.2.0/24
|
|
||||||
QBT_Preferences__WebUI__LocalHostAuth: false
|
|
||||||
CROSS_SEED_HOST: cross-seed.qbittorrent.svc.cluster.local
|
CROSS_SEED_HOST: cross-seed.qbittorrent.svc.cluster.local
|
||||||
CROSS_SEED_PORT: 80
|
CROSS_SEED_PORT: 80
|
||||||
CROSS_SEED_SLEEP_INTERVAL: 0
|
CROSS_SEED_SLEEP_INTERVAL: 0
|
||||||
|
PUSHOVER_ENABLED: true
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: qbittorrent-secret
|
name: qbittorrent-secret
|
||||||
resources:
|
probes:
|
||||||
requests:
|
liveness:
|
||||||
cpu: 49m
|
enabled: true
|
||||||
memory: 1024Mi
|
readiness:
|
||||||
limits:
|
enabled: true
|
||||||
memory: 24Gi
|
startup:
|
||||||
|
enabled: true
|
||||||
|
spec:
|
||||||
|
failureThreshold: 30
|
||||||
|
periodSeconds: 10
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsUser: 568
|
runAsUser: 568
|
||||||
runAsGroup: 568
|
runAsGroup: 568
|
||||||
|
@ -69,7 +66,22 @@ spec:
|
||||||
capabilities:
|
capabilities:
|
||||||
drop:
|
drop:
|
||||||
- ALL
|
- 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:
|
service:
|
||||||
app:
|
app:
|
||||||
controller: *app
|
controller: *app
|
||||||
|
@ -107,21 +119,11 @@ spec:
|
||||||
name: qbittorrent-scripts
|
name: qbittorrent-scripts
|
||||||
defaultMode: 0775
|
defaultMode: 0775
|
||||||
globalMounts:
|
globalMounts:
|
||||||
- path: /scripts/cross-seed.sh
|
- readOnly: true
|
||||||
subPath: cross-seed.sh
|
|
||||||
readOnly: true
|
|
||||||
media:
|
media:
|
||||||
type: nfs
|
type: nfs
|
||||||
server: 10.1.1.13
|
server: gandalf.jahanson.tech
|
||||||
path: /eru/media
|
path: /eru/media
|
||||||
advancedMounts:
|
globalMounts:
|
||||||
qbittorrent:
|
- path: /data/nas-media/qb
|
||||||
app:
|
subPath: nas-media/qb
|
||||||
- path: /data/nas-media
|
|
||||||
qbtun:
|
|
||||||
type: hostPath
|
|
||||||
hostPath: /dev/net
|
|
||||||
advancedMounts:
|
|
||||||
qbittorrent:
|
|
||||||
gluetun:
|
|
||||||
- path: /dev/net
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ resources:
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: qbittorrent-scripts
|
- name: qbittorrent-scripts
|
||||||
files:
|
files:
|
||||||
- cross-seed.sh=./resources/cross-seed.sh
|
- post-process.sh=./resources/post-process.sh
|
||||||
generatorOptions:
|
generatorOptions:
|
||||||
disableNameSuffixHash: true
|
disableNameSuffixHash: true
|
||||||
annotations:
|
annotations:
|
||||||
|
|
|
@ -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}"
|
|
|
@ -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 \
|
||||||
|
"<b>%s</b><small>\n<b>Category:</b> %s</small><small>\n<b>Indexer:</b> %s</small><small>\n<b>Size:</b> %s</small>" \
|
||||||
|
"${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 "$@"
|
Loading…
Reference in a new issue