#!/bin/bash # # Title: PGBlitz (Reference Title File) # Author(s): Admin9705 # URL: https://pgblitz.com - http://github.pgblitz.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/communityapps/apps/_core.yml' - name: 'Including required folders' include_tasks: '/opt/communityapps/apps/_downloaders.yml' - name: 'Including plugins' include_tasks: '/opt/communityapps/apps/_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}}' traefik.frontend.headers.SSLHost: '{{domain.stdout}}' traefik.frontend.headers.SSLRedirect: 'true' traefik.frontend.headers.STSIncludeSubdomains: 'true' traefik.frontend.headers.STSPreload: 'true' traefik.frontend.headers.STSSeconds: '315360000' traefik.frontend.headers.browserXSSFilter: 'true' traefik.frontend.headers.contentTypeNosniff: 'true' traefik.frontend.headers.customResponseHeaders: 'X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex' traefik.frontend.headers.forceSTSHeader: 'true' - 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}}' - '{{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 - name: Set download location lineinfile: path: '/opt/appdata/{{pgrole}}/core.conf' regexp: '"download_location".*' line: '"download_location": "{{path.stdout}}/incomplete/{{pgrole}}",' state: present - 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