diff --git a/apps/deluge.yml b/apps/deluge.yml new file mode 100644 index 0000000..6b46901 --- /dev/null +++ b/apps/deluge.yml @@ -0,0 +1,276 @@ +#!/bin/bash +# +# Title: PlexGuide (Reference Title File) +# Author(s): Admin9705 +# URL: https://plexguide.com - http://github.plexguide.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + - name: 'Set Known Facts' + set_fact: + pgrole: 'deluge' + intport: '8112' + extport: '8112' + intport2: '58846' + extport2: '58846' + intport3: '58946' + extport3: '58946' + image: 'linuxserver/deluge' + + # CORE (MANDATORY) ############################################################ + - name: 'Including cron job' + include_tasks: '/opt/plexguide/containers/_core.yml' + + - name: 'Including required folders' + include_tasks: '/opt/plexguide/containers/_downloaders.yml' + + - name: 'Including plugins' + include_tasks: '/opt/plexguide/containers/_plugins.yml' + + - name: 'Checking for existing app data' + stat: + path: /opt/appdata/{{pgrole}}/core.conf + register: confcheck + + # LABELS ###################################################################### + - name: 'Adding Traefik' + set_fact: + pg_labels: + traefik.frontend.auth.forward.address: '{{gauth}}' + traefik.enable: 'true' + traefik.port: '{{intport}}' + traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}' + + - name: 'Setting PG Volumes' + set_fact: + pg_volumes: + - '/opt/appdata/{{pgrole}}:/config' + - '{{path.stdout}}:{{path.stdout}}' + - '/etc/localtime:/etc/localtime:ro' + - '/mnt:/mnt' + + - name: 'Setting PG ENV' + set_fact: + pg_env: + PUID: 1000 + PGID: 1000 + + # MAIN DEPLOYMENT ############################################################# + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + - '{{ports.stdout}}{{extport2}}:{{intport2}}' + - '{{ports.stdout}}{{extport3}}:{{intport3}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: unless-stopped + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: started + labels: '{{pg_labels}}' + + # CONFIGURATION ########################################################### + - name: 'Waiting for {{pgrole}} to initialize' + wait_for: + timeout: 10 + + - name: Stopping {{pgrole}} + docker_container: + name: '{{pgrole}}' + state: stopped + + - name: 'Checking for appdata' + wait_for: + path: '/opt/appdata/{{pgrole}}/core.conf' + state: present + delay: 5 + + - name: Setting plugins directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"plugins_location".*' + line: '"plugins_location": "/config/plugins",' + state: present + + - name: Set move completed location + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"move_completed_path".*' + line: '"move_completed_path": "{{path.stdout}}/downloads/{{pgrole}}",' + state: present + when: incomplete.stdout | length == 0 + + - name: Set download location + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"download_location".*' + line: '"download_location": "{{path.stdout}}/incomplete/{{pgrole}}",' + state: present + when: incomplete.stdout | length == 0 + + - name: Set download location + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"download_location".*' + line: '"download_location": "{{incomplete.stdout}}/{{pgrole}}",' + state: present + when: incomplete.stdout | length > 0 + + - name: Setting torrent file directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"torrentfiles_location".*' + line: '"torrentfiles_location": "{{path.stdout}}/torrent",' + state: present + + - name: Setting torrent watch directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"autoadd_location".*' + line: '"autoadd_location": "{{path.stdout}}/torrent/watch",' + state: present + + - name: Setting move_completed + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"move_completed".*' + line: '"move_completed": true,' + state: present + + - name: Setting extractor folder + lineinfile: + path: '/opt/appdata/{{pgrole}}/plugins/extractor.conf' + regexp: '"use_name_folder".*' + line: '"use_name_folder": true,' + state: present + + - name: Setting extractor + lineinfile: + path: '/opt/appdata/{{pgrole}}/plugins/extractor.conf' + regexp: '"extract_path".*' + line: '"extract_path": "{{path.stdout}}/downloads/deluge"' + state: present + + # FIRST TIME CONFIGURATION #################################################### + - name: 'Configuring {{pgrole}} for first time use' + block: + - name: set enabled_plugins + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enabled_plugins".*' + line: '"enabled_plugins": ["Extractor", "Label"],' + state: present + + - name: set compact_allocation + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"compact_allocation".*' + line: '"compact_allocation": true,' + state: present + + - name: set stop_seed_ratio + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"stop_seed_ratio"".*' + line: '"stop_seed_ratio": 1.0,' + state: present + + - name: set share_ratio_limit + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"share_ratio_limit".*' + line: '"share_ratio_limit": 1.0,' + state: present + + - name: set remove_seed_at_ratio + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"remove_seed_at_ratio".*' + line: '"remove_seed_at_ratio": true,' + state: present + + - name: set enc_prefer_rc4 + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_prefer_rc4".*' + line: '"enc_prefer_rc4": true,' + state: present + + - name: set enc_level + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_level".*' + line: '"enc_level": 1,' + state: present + + - name: set enc_in_policy + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_in_policy".*' + line: '"enc_in_policy": 1,' + state: present + + - name: set enc_out_policy + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_out_policy".*' + line: '"enc_out_policy": 1,' + state: present + + - name: set max_active_downloading + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"max_active_downloading".*' + line: '"max_active_downloading": 4,' + state: present + + - name: set dont_count_slow_torrents + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"dont_count_slow_torrents".*' + line: '"dont_count_slow_torrents": true,' + state: present + + - name: set max_active_seeding + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enabled_plugins".*' + line: '"max_active_seeding": 8,' + state: present + + - name: set share_ratio_limit + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"share_ratio_limit".*' + line: '"share_ratio_limit": 1,' + state: present + + - name: set stop_seed_at_ratio + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"stop_seed_at_ratio".*' + line: '"stop_seed_at_ratio": 1.0,' + state: present + + - name: set seed_time_ratio_limit + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"seed_time_ratio_limit".*' + line: '"seed_time_ratio_limit": 1.0,' + state: present + when: not confcheck.stat.exists + + - name: Restart {{pgrole}} + docker_container: + name: '{{pgrole}}' + state: started diff --git a/apps/deluge/plugins/autoremoveplus.conf b/apps/deluge/plugins/autoremoveplus.conf new file mode 100644 index 0000000..f23c6ba --- /dev/null +++ b/apps/deluge/plugins/autoremoveplus.conf @@ -0,0 +1,23 @@ +{ + "file": 1, + "format": 1 +}{ + "interval": 1.0, + "max_seeds": 0, + "sel_func": "or", + "trackers": [], + "remove_data": true, + "labels": [], + "enabled": true, + "count_exempt": false, + "remove": true, + "filter": "func_ratio", + "tracker_rules": {}, + "min": 1.5, + "hdd_space": -1.0, + "filter2": "func_seed_time", + "rule_2_enabled": true, + "min2": 15.0, + "rule_1_enabled": true, + "label_rules": {} +} \ No newline at end of file diff --git a/apps/deluge/plugins/core.conf b/apps/deluge/plugins/core.conf new file mode 100644 index 0000000..c3bbdf3 --- /dev/null +++ b/apps/deluge/plugins/core.conf @@ -0,0 +1,104 @@ +{ + "file": 1, + "format": 1 +}{ + "info_sent": 0.0, + "lsd": false, + "send_info": false, + "move_completed_path": "{{ downloads }}/complete", + "enc_in_policy": 1, + "queue_new_to_top": true, + "ignore_limits_on_local_network": true, + "rate_limit_ip_overhead": false, + "daemon_port": 58846, + "natpmp": true, + "max_active_limit": "{{ max_active_limit }}", + "utpex": false, + "max_active_downloading": 5, + "max_active_seeding": 10, + "allow_remote": true, + "max_half_open_connections": 50, + "download_location": "{{ downloads }}/incomplete", + "compact_allocation": false, + "max_upload_speed": -1.0, + "cache_expiry": 60, + "prioritize_first_last_pieces": false, + "auto_managed": true, + "enc_level": 2, + "max_connections_per_second": 20, + "dont_count_slow_torrents": true, + "random_outgoing_ports": true, + "max_upload_slots_per_torrent": -1, + "new_release_check": false, + "enc_out_policy": 1, + "outgoing_ports": [ + 0, + 0 + ], + "seed_time_limit": 180, + "cache_size": 512, + "share_ratio_limit": 2.0, + "max_download_speed": -1.0, + "geoip_db_location": "/usr/share/GeoIP/GeoIP.dat", + "torrentfiles_location": "/data/torrents", + "stop_seed_at_ratio": false, + "peer_tos": "0x00", + "listen_interface": "0.0.0.0", + "upnp": true, + "max_download_speed_per_torrent": -1, + "max_upload_slots_global": 4, + "enabled_plugins": [ + "Label", + "Execute" + ], + "random_port": false, + "autoadd_enable": false, + "max_connections_global": 200, + "enc_prefer_rc4": true, + "listen_ports": [ + 58946, + 58946 + ], + "dht": false, + "stop_seed_ratio": 1.5, + "seed_time_ratio_limit": 7.0, + "max_upload_speed_per_torrent": -1, + "copy_torrent_file": false, + "del_copy_torrent_file": false, + "move_completed": true, + "proxies": { + "peer": { + "username": "", + "password": "", + "type": 0, + "hostname": "", + "port": 8080 + }, + "web_seed": { + "username": "", + "password": "", + "type": 0, + "hostname": "", + "port": 8080 + }, + "tracker": { + "username": "", + "password": "", + "type": 0, + "hostname": "", + "port": 8080 + }, + "dht": { + "username": "", + "password": "", + "type": 0, + "hostname": "", + "port": 8080 + } + }, + "add_paused": false, + "max_connections_per_torrent": -1, + "remove_seed_at_ratio": true, + "autoadd_location": "/data/watched", + "plugins_location": "/config/plugins" +} \ No newline at end of file diff --git a/apps/deluge/plugins/execute.conf b/apps/deluge/plugins/execute.conf new file mode 100644 index 0000000..f0f83b0 --- /dev/null +++ b/apps/deluge/plugins/execute.conf @@ -0,0 +1,12 @@ +{ + "file": 1, + "format": 1 +}{ + "commands": [ + [ + "0", + "complete", + "/config/scripts/extract.sh" + ] + ] +} \ No newline at end of file diff --git a/apps/deluge/plugins/extractor.conf b/apps/deluge/plugins/extractor.conf new file mode 100644 index 0000000..32e8ff4 --- /dev/null +++ b/apps/deluge/plugins/extractor.conf @@ -0,0 +1,7 @@ +{ + "file": 1, + "format": 1 +}{ + "use_name_folder": true, + "extract_path": "/downloads/deluge/" +} diff --git a/apps/deluge/plugins/label0.conf b/apps/deluge/plugins/label0.conf new file mode 100644 index 0000000..2b3d517 --- /dev/null +++ b/apps/deluge/plugins/label0.conf @@ -0,0 +1,26 @@ +{ + "file": 1, + "format": 1 +}{ + "labels": { + "main": { + "max_download_speed": -1, + "stop_at_ratio": true, + "apply_move_completed": false, + "apply_queue": true, + "auto_add": false, + "max_upload_slots": -1, + "prioritize_first_last": false, + "move_completed": false, + "max_connections": -1, + "is_auto_managed": true, + "max_upload_speed": -1, + "auto_add_trackers": [], + "remove_at_ratio": false, + "stop_ratio": 0, + "move_completed_path": "", + "apply_max": false + } + }, + "torrent_labels": {} +} \ No newline at end of file diff --git a/apps/deluge/scripts/deluge_extract.sh b/apps/deluge/scripts/deluge_extract.sh new file mode 100644 index 0000000..9c14361 --- /dev/null +++ b/apps/deluge/scripts/deluge_extract.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Copied from https://github.com/Radarr/Radarr/wiki/Common-Problems on August 19, 2018 +# the Radarr script was originally sourced from https://dev.deluge-torrent.org/wiki/Plugins/Execute + +formats=(zip rar) +commands=([zip]="unzip -u" [rar]="unrar -r -o- e") +extraction_subdir='deluge_extracted' + +torrentid=$1 +torrentname=$2 +torrentpath=$3 + +log() +{ + logger -t deluge-extractarchives "$@" +} + +log "Torrent complete: $@" +cd "${torrentpath}" +for format in "${formats[@]}"; do + while read file; do + log "Extracting \"$file\"" + cd "$(dirname "$file")" + file=$(basename "$file") + # if extraction_subdir is not empty, extract to subdirectory + if [[ ! -z "$extraction_subdir" ]] ; then + mkdir "$extraction_subdir" + cd "$extraction_subdir" + file="../$file" + fi + ${commands[$format]} "$file" + done < <(find "$torrentpath/$torrentname" -iname "*.${format}" ) +done \ No newline at end of file