From b070d1cbd08aa07591b35cc3bfcffecf845d83a3 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Tue, 2 Jan 2024 16:24:38 -0500 Subject: [PATCH] feat(qbittorrent): add qBit Manage --- .../download/qbittorrent/helm-release.yaml | 64 +++- .../download/qbittorrent/kustomization.yaml | 1 + .../qbittorrent/qbit-manage-config.yaml | 288 ++++++++++++++++++ 3 files changed, 342 insertions(+), 11 deletions(-) create mode 100644 cluster/apps/download/qbittorrent/qbit-manage-config.yaml diff --git a/cluster/apps/download/qbittorrent/helm-release.yaml b/cluster/apps/download/qbittorrent/helm-release.yaml index 1739600c..1ecec1ae 100644 --- a/cluster/apps/download/qbittorrent/helm-release.yaml +++ b/cluster/apps/download/qbittorrent/helm-release.yaml @@ -19,25 +19,38 @@ spec: repository: lscr.io/linuxserver/qbittorrent tag: "4.5.4" - # Metrics sidecar + initContainers: + copy-manage-config: + image: alpine:3.18 + command: + - /bin/sh + - -c + - "ls /tmp/manage-ro + && cp -a /tmp/manage-ro/. /tmp/manage-tmp/ + && chmod -R 777 /tmp/manage-tmp + && ls /tmp/manage-tmp" + volumeMounts: + - name: manage-ro + mountPath: /tmp/manage-ro + - name: manage-tmp + mountPath: /tmp/manage-tmp + sidecars: gluetun: image: qmcgaw/gluetun:v3.36 env: -# - name: FIREWALL_VPN_INPUT_PORTS -# value: "40574" - - name: FIREWALL_INPUT_PORTS - value: "8080,17871" # 17871 is the prometheus exporter + - name: FIREWALL_INPUT_PORTS + value: "8080,17871" # 17871 is the prometheus exporter envFrom: - secretRef: name: qbittorrent-secrets securityContext: capabilities: add: - - NET_ADMIN + - NET_ADMIN volumeMounts: - - name: gluetun-tmp - mountPath: /tmp/gluetun/ + - name: gluetun-tmp + mountPath: /tmp/gluetun/ port-manager: image: git.seanomik.net/seanomik/gluetun-qbit-port-updater:v0.1.1 @@ -50,8 +63,8 @@ spec: PORT_UPD_QBITTORRENT_PASSWORD: &qbitPass adminadmin PORT_UPD_PORT_FILE: /tmp/gluetun/forwarded_port volumeMounts: - - name: gluetun-tmp - mountPath: /tmp/gluetun/ + - name: gluetun-tmp + mountPath: /tmp/gluetun/ metrics: image: caseyscarborough/qbittorrent-exporter:v1.3.2 @@ -64,6 +77,17 @@ spec: - name: metrics containerPort: 17871 + manage: + image: bobokun/qbit_manage:v4.0.6 + env: + QBT_STARTUP_DELAY: 45 # seconds + QBT_SCHEDULE: 720 # 720min = 12hr + volumeMounts: + - name: manage-tmp + mountPath: /config + - name: storage + mountPath: /storage/Torrents + env: TZ: America/New_York PGID: "10000" @@ -120,7 +144,25 @@ spec: gluetun-tmp: enabled: true type: emptyDir - +# qbit-manage: +# enabled: true +# type: hostPath +# hostPath: /mnt/MainPool/Kubernetes/qbit-manage +# mountPath: /config-manage + manage-tmp: + enabled: true + type: emptyDir + manage-ro: + enabled: true + type: custom + mountPath: /config-manage + volumeSpec: + configMap: + name: qbit-manage + items: + - key: "config.yml" + path: "config.yml" + resources: requests: cpu: 10m diff --git a/cluster/apps/download/qbittorrent/kustomization.yaml b/cluster/apps/download/qbittorrent/kustomization.yaml index 2a9073d1..c87bde6c 100644 --- a/cluster/apps/download/qbittorrent/kustomization.yaml +++ b/cluster/apps/download/qbittorrent/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ./qbittorrent-secrets.sops.yaml +- ./qbit-manage-config.yaml - ./helm-release.yaml - ./qbittorrent-metrics.yaml - ./dashboard.yaml diff --git a/cluster/apps/download/qbittorrent/qbit-manage-config.yaml b/cluster/apps/download/qbittorrent/qbit-manage-config.yaml new file mode 100644 index 00000000..08033d08 --- /dev/null +++ b/cluster/apps/download/qbittorrent/qbit-manage-config.yaml @@ -0,0 +1,288 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: qbit-manage + namespace: download +data: + config.yml: |- + commands: + # The commands defined below will IGNORE any commands used in command line and docker env variables. + dry_run: False + cross_seed: False + recheck: False + cat_update: False + tag_update: True + rem_unregistered: False + tag_tracker_error: True + rem_orphaned: True + tag_nohardlinks: True + share_limits: False + skip_qb_version_check: False + skip_cleanup: False + + qbt: + # qBittorrent parameters + host: "localhost:8080" + user: "admin" + pass: "adminadmin" + + settings: + force_auto_tmm: False # Will force qBittorrent to enable Automatic Torrent Management for each torrent. + tracker_error_tag: issue # Will set the tag of any torrents that do not have a working tracker. + nohardlinks_tag: noHL # Will set the tag of any torrents with no hardlinks. + share_limits_tag: ~share_limit # Will add this tag when applying share limits to provide an easy way to filter torrents by share limit group/priority for each torrent + ignoreTags_OnUpdate: # When running tag-update function, it will update torrent tags for a given torrent even if the torrent has at least one or more of the tags defined here. Otherwise torrents will not be tagged if tags exist. + - noHL + - issue + - cross-seed + directory: + # Do not remove these + # Cross-seed var: # Output directory of cross-seed + # root_dir var: # Root downloads directory used to check for orphaned files, noHL, and RecycleBin. + # remote_dir var: # Path of docker host mapping of root_dir. + # remote_dir must be set if you're running qbit_manage locally and qBittorrent/cross_seed is in a docker + # remote_dir should not be set if qbit_manage is running in a container + # recycle_bin var: # Path of the RecycleBin folder. Default location is set to remote_dir/.RecycleBin + # torrents_dir var: # Path of the your qbittorrent torrents directory. Required for `save_torrents` attribute in recyclebin + # orphaned_dir var: # Path of the the Orphaned Data folder. This is similar to RecycleBin, but only for orphaned data. + cross_seed: "/your/path/here/" + root_dir: "/storage/Torrents/" + remote_dir: "/storage/Torrents/" + recycle_bin: "/storage/Torrents/.RecycleBin" + #torrents_dir: "/storage/Torrents/BT_backup" + orphaned_dir: "/storage/Torrents/orphaned_data" + + cat: + # Category & Path Parameters + # : # Path of your save directory. + radarr: "/storage/Torrents/radarr" + sonarr: "/storage/Torrents/sonarr" + readarr: "/storage/Torrents/readarr" + readarr-audiobooks: "/storage/Torrents/readarr-audiobooks" + farming: "/storage/Torrents/farming" + + cat_change: + # This moves all the torrents from one category to another category. This executes on --cat-update + # WARNING: if the paths are different and Default Torrent Management Mode is set to automatic the files could be moved !!! + # : + # Radarr-HD.cross-seed: movies-hd + + tracker: + # Mandatory + # Tag Parameters + # : # This is the keyword in the tracker url. You can define multiple tracker urls by splitting with `|` delimiter + # Set tag name. Can be a list of tags or a single tag + # tag: + # Set the category based on tracker URL. This category option takes priority over the category defined by save directory + # cat: + # Set this to the notifiarr react name. This is used to add indexer reactions to the notifications sent by Notifiarr + # notifiarr: + alpharatio: + tag: [AlphaRatio, Private] + animetorrents.me: + tag: [AnimeZ, Private] + myanonamouse: + tag: [MaM, Private] + privatehd: + tag: [PrivateHD, Private] + torrentleech|tleechreload: + tag: [TorrentLeech, Private] + bakabt.me: + tag: [BakaBT, Private] + opsfet.ch: + tag: [Orpheus, Private] + + # The "other" key is a special keyword and if defined will tag any other trackers that don't match the above trackers into this tag + other: + tag: other + + nohardlinks: + # Tag Movies/Series that are not hard linked outside the root directory + # Mandatory to fill out directory parameter above to use this function (root_dir/remote_dir) + # This variable should be set to your category name of your completed movies/completed series in qbit. Acceptable variable can be any category you would like to tag if there are no hardlinks found + # - movies-completed-4k + # - series-completed-4k + - radarr: + # exclude_tags var: Will exclude torrents with any of the following tags when searching through the category. + exclude_tags: + - MaM + - Orpheus + # Can have additional categories set with separate ratio/seeding times defined. + - sonarr: + # exclude_tags var: Will exclude torrents with any of the following tags when searching through the category. + exclude_tags: + - MaM + - Orpheus + + share_limits: + # Control how torrent share limits are set depending on the priority of your grouping + # Each torrent will be matched with the share limit group with the highest priority that meets the group filter criteria. + # Each torrent can only be matched with one share limit group + # This variable is mandatory and is a text defining the name of your grouping. This can be any string you want + #noHL: + # # priority: # This is the priority of your grouping. The lower the number the higher the priority + # priority: 1 + # # include_all_tags: # Filter the group based on one or more tags. Multiple include_all_tags are checked with an AND condition + # # All tags defined here must be present in the torrent for it to be included in this group + # include_all_tags: + # - noHL + # # include_any_tags: # Filter the group based on one or more tags. Multiple include_any_tags are checked with an OR condition + # # Any tags defined here must be present in the torrent for it to be included in this group + # include_any_tags: + # - noHL + # # exclude_all_tags: # Filter by excluding one or more tags. Multiple exclude_all_tags are checked with an AND condition + # # This is useful to combine with the category filter to exclude one or more tags from an entire category + # # All tags defined here must be present in the torrent for it to be excluded in this group + # #exclude_all_tags: + # # - Beyond-HD + # # exclude_any_tags: # Filter by excluding one or more tags. Multiple exclude_any_tags are checked with an OR condition + # # This is useful to combine with the category filter to exclude one or more tags from an entire category + # # Any tags defined here must be present in the torrent for it to be excluded in this group + # #exclude_any_tags: + # # - Beyond-HD + # # categories: # Filter by including one or more categories. Multiple categories are checked with an OR condition + # # Since one torrent can only be associated with a single category, multiple categories are checked with an OR condition + # categories: + # - radarr + # - sonarr + # # max_ratio : Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading. + # # Will default to -1 (no limit) if not specified for the group. + # max_ratio: 5.0 + # # max_seeding_time : Will set the torrent Maximum seeding time (minutes) until torrent is stopped from seeding. + # # Will default to -1 (no limit) if not specified for the group. + # max_seeding_time: 129600 + # # min_seeding_time : Will prevent torrent deletion by cleanup variable if torrent has not yet minimum seeding time (minutes). + # # If the torrent has not yet reached this minimum seeding time, it will change the share limits back to no limits and resume the torrent to continue seeding. + # # Will default to 0 if not specified for the group. + # min_seeding_time: 43200 + # # last_active : Will prevent torrent deletion by cleanup variable if torrent has been active within the last x minutes. + # # If the torrent has been active within the last x minutes, it will change the share limits back to no limits and resume the torrent to continue seeding. + # # Will default to 0 if not specified for the group. + # last_active: 43200 + # # Limit Upload Speed : Will limit the upload speed KiB/s (KiloBytes/second) (`-1` : No Limit) + # limit_upload_speed: 0 + # # cleanup : WARNING!! Setting this as true Will remove and delete contents of any torrents that satisfies the share limits + # cleanup: false + # # resume_torrent_after_change : This variable will resume your torrent after changing share limits. Default is true + # resume_torrent_after_change: true + # # add_group_to_tag : This adds your grouping as a tag with a prefix defined in settings . Default is true + # # Example: A grouping defined as noHL will have a tag set to ~share_limit.noHL (if using the default prefix) + # add_group_to_tag: true + # # min_num_seeds : This will prevent torrent deletion by cleanup variable if the number of seeds is less than the value set here. + # # If the torrent has less number of seeds than the min_num_seeds, the share limits will be changed back to no limits and resume the torrent to continue seeding. + # # Will default to 0 if not specified for the group. + # min_num_seeds: 0 + + #cross-seed: + # priority: 2 + # include_all_tags: + # - cross-seed + # max_seeding_time: 10200 + # cleanup: false + + #PTP: + # priority: 3 + # include_all_tags: + # - PassThePopcorn + # max_ratio: 2.0 + # max_seeding_time: 130000 + # cleanup: false + + private: + priority: 3 + include_all_tags: + - Private + include_any_tags: + - Private + max_ratio: -1 + max_seeding_time: -1 + cleanup: false + + farming: + priority: 4 + categories: + - farming + max_ratio: -1 + max_seeding_time: -1 + cleanup: false + + default: + priority: 999 + max_ratio: 1.5 + max_seeding_time: 14400 # 14400 min = 10 days + cleanup: false + + recyclebin: + # Recycle Bin method of deletion will move files into the recycle bin (Located in /root_dir/.RecycleBin) instead of directly deleting them in qbit + # By default the Recycle Bin will be emptied on every run of the qbit_manage script if empty_after_x_days is defined. + enabled: true + # empty_after_x_days var: + # Will automatically remove all files and folders in recycle bin after x days. (Checks every script run) + # If this variable is not defined it, the RecycleBin will never be emptied. + # WARNING: Setting this variable to 0 will delete all files immediately upon script run! + empty_after_x_days: 60 + # save_torrents var: + # If this option is set to true you MUST fill out the torrents_dir in the directory attribute. + # This will save a copy of your .torrent and .fastresume file in the recycle bin before deleting it from qbittorrent + save_torrents: false + # split_by_category var: + # This will split the recycle bin folder by the save path defined in the `cat` attribute + # and add the base folder name of the recycle bin that was defined in the `recycle_bin` sub-attribute under directory. + split_by_category: true + + orphaned: + # Orphaned files are those in the root_dir download directory that are not referenced by any active torrents. + # Will automatically remove all files and folders in orphaned data after x days. (Checks every script run) + # If this variable is not defined it, the orphaned data will never be emptied. + # WARNING: Setting this variable to 0 will delete all files immediately upon script run! + empty_after_x_days: 60 + # File patterns that will not be considered orphaned files. Handy for generated files that aren't part of the torrent but belong with the torrent's files + exclude_patterns: + - "**/.DS_Store" + - "**/Thumbs.db" + - "**/@eaDir" + - "/storage/Torrents/.incomplete/**" + - "**/*.!qB" + - "**/*_unpackerred" + + apprise: + # Apprise integration with webhooks + # Leave Empty/Blank to disable + # Mandatory to fill out the url of your apprise API endpoint + api_url: http://apprise-api:8000 + # Mandatory to fill out the notification url/urls based on the notification services provided by apprise. https://github.com/caronc/apprise/wiki + notify_url: + + notifiarr: + # Notifiarr integration with webhooks + # Leave Empty/Blank to disable + # Mandatory to fill out API Key + apikey: + # Set to a unique value (could be your username on notifiarr for example) + instance: + + webhooks: + # Webhook notifications: + # Possible values: + # Set value to notifiarr if using notifiarr integration + # Set value to apprise if using apprise integration + # Set value to a valid webhook URL + # Set value to nothing (leave Empty/Blank) to disable + error: + run_start: notifiarr + run_end: apprise + function: + cross_seed: https://mywebhookurl.com/qbt_manage + recheck: notifiarr + cat_update: apprise + tag_update: notifiarr + rem_unregistered: notifiarr + tag_tracker_error: notifiarr + rem_orphaned: notifiarr + tag_nohardlinks: notifiarr + share_limits: notifiarr + cleanup_dirs: notifiarr + + bhd: + # BHD Integration used for checking unregistered torrents + apikey: \ No newline at end of file