Create rflood.yml

This commit is contained in:
Michael
2020-01-15 10:17:29 +00:00
committed by GitHub
parent a5d1fa93bf
commit e50a1ecc61

338
apps/rflood.yml Normal file
View File

@@ -0,0 +1,338 @@
#!/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: 'rflood'
intport: '80'
extport: '8991'
intport2: '5000'
extport2: '5001'
intport3: '51413'
extport3: '51411'
image: 'romancin/rutorrent-flood:latest'
# CORE (MANDATORY) ############################################################
- name: 'Including cron job'
include_tasks: '/opt/coreapps/apps/_core.yml'
- name: 'Including folders'
include_tasks: '/opt/coreapps/apps/_downloaders.yml'
# PLUGINS ####################################################
- name: Delete stock themes
shell: 'path={{item}} state=absent'
with_items:
- '/opt/appdata/{{pgrole}}/plugins/mobile'
- '/opt/appdata/{{pgrole}}/plugins/theme/themes/FlatUI_Dark'
- name: 'Including plugins'
include_tasks: '/opt/coreapps/apps/_plugins.yml'
- name: Checking for existing app data
stat:
path: '/opt/appdata/{{pgrole}}/rutorrent/rtorrent/rtorrent.rc'
register: rccheck
# 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}}{{cname}}'
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:
- '/etc/localtime:/etc/localtime:ro'
- '{{path.stdout}}:{{path.stdout}}'
- '/mnt:/mnt'
- '/opt/appdata/{{pgrole}}:/config'
- '/opt/appdata/{{pgrole}}/sock:/run/php'
- name: 'Setting PG ENV'
set_fact:
pg_env:
PUID: '1000'
PGID: '1000'
- name: 'Install config.php fix'
template:
src: /opt/coreapps/apps/templates/rutorrent/rutorrent/settings/config.php
dest: /opt/appdata/rutorrent/rutorrent/settings/config.php
force: yes
owner: '1000'
group: '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
purge_networks: yes
stop_timeout: '240'
labels: '{{pg_labels}}'
# CONFIGURATION ####################################################
- name: 'Waiting for {{pgrole}} to initialize'
wait_for:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
state: present
msg: rtorrent.rc creation failed
- name: 'Stopping {{pgrole}}'
docker_container:
name: '{{pgrole}}'
state: stopped
# This is needed for rutorrent b/c it's weird.
- name: 'Setting ownership on appdata recursivley (this can take a while!)'
shell: 'chown -R 1000:1000 /opt/appdata/{{pgrole}}'
- name: 'Setting permissions on appdata recursivley (this can take a while!)'
shell: 'chmod -R 775 /opt/appdata/{{pgrole}}'
- name: Set download location
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*directory\s*=.*'
line: 'directory = {{path.stdout}}/downloads/{{pgrole}}'
state: present
- name: Set download location
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*directory.default.set\s*=.*'
line: 'directory.default.set = {{path.stdout}}/downloads/{{pgrole}}'
state: present
# - name: Set download completed move location
# lineinfile:
# path: "/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc"
# regexp: '#*method.insert\s*=\s*d.get_finished_dir.*'
# line: 'method.insert = d.get_finished_dir, simple, "cat={path.stdout}}/downloads/{{pgrole}}/,$d.custom1="'
# state: present
# - name: Set download data path location
# lineinfile:
# path: "/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc"
# regexp: '#*method.insert\s*=\s*d.data_path.*'
# line: 'method.insert = d.data_path, simple, "if=(d.is_multi_file), (cat,(d.directory),/), (cat,(d.directory),/,(d.name))"'
# state: present
# - name: Enable download completed move
# lineinfile:
# path: "/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc"
# regexp: '#*method.insert\s*=\s*d.move_to_complete,\s*simple.*'
# line: 'method.insert = d.move_to_complete, simple, "d.directory.set=$argument.1=; execute=mkdir,-p,$argument.1=; execute=mv,-u,$argument.0=,$argument.1=; d.save_full_session="'
# state: present
# - name: Enable download completed move event
# lineinfile:
# path: "/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc"
# regexp: '#*method.set_key\s*=\s*event.download.finished,move_complete.*'
# line: 'method.set_key = event.download.finished,move_complete,"d.move_to_complete=$d.data_path=,$d.get_finished_dir="'
# state: present
# FIRST TIME CONFIGURATION ####################################################
- name: 'Configuring {{pgrole}} for first time use'
block:
- name: Upload Rate
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*upload_rate\s*=.*'
line: 'upload_rate = 0'
state: present
- name: Download Rate
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*download_rate\s*=.*'
line: 'download_rate = 0'
state: present
- name: max_downloads
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*throttle.max_downloads.global.set\s*=.*'
line: 'throttle.max_downloads.global.set = 500'
state: present
- name: max_uploads
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*throttle.max_uploads.global.set\s*=.*'
line: 'throttle.max_uploads.global.set = 50'
state: present
- name: No File Allocation
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*system.file.allocate.set\s*=.*'
line: 'system.file.allocate.set = 0'
state: present
- name: min_peers
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*min_peers\s*=.*'
line: 'min_peers = 40'
state: present
- name: max_peers
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*max_peers\s*=.*'
line: 'max_peers = 1200'
state: present
- name: max_uploads
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*max_uploads\s*=.*'
line: 'max_uploads = 15'
state: present
- name: max_downloads
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*max_downloads\s*=.*'
line: 'max_downloads = 10'
state: present
- name: Upload Rate
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*upload_rate\s*=.*'
line: 'upload_rate = 0'
state: present
- name: Download Rate
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*download_rate\s*=.*'
line: 'download_rate = 0'
state: present
- name: Global Upload to Unlmited
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*throttle.global_up.max_rate.set_kb\s*=.*'
line: 'throttle.global_up.max_rate.set_kb = 0'
state: present
- name: DHT disable
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*dht\s*=.*'
line: '#dht = auto'
state: present
- name: DHT port
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*dht_port\s*=.*'
line: '#dht_port = 6881'
state: present
- name: check Hash
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*check_hash\s*=.*'
line: 'check_hash = no'
state: present
- name: Preload Piece to Host
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*pieces.preload.type\s*=.*'
line: 'pieces.preload.type = 2'
state: present
- name: lower DNS timeout
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*network.http.dns_cache_timeout.set\s*=.*'
line: 'network.http.dns_cache_timeout.set = 25'
state: present
- name: Network Send Buffer Size
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*network.send_buffer.size.set\s*=.*'
line: 'network.send_buffer.size.set = 12M'
state: present
- name: Network Recived Buffer Size
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*network.receive_buffer.size.set\s*=.*'
line: 'network.receive_buffer.size.set = 4M'
state: present
- name: Announce-Interval Min rescan
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*throttle.min_peers.seed.set\s*=.*'
line: 'throttle.min_peers.seed.set = 0'
state: present
- name: Announce-Interval Max rescan
lineinfile:
path: '/opt/appdata/{{pgrole}}/rtorrent/rtorrent.rc'
regexp: '#*throttle.max_peers.seed.set\s*=.*'
line: 'throttle.max_peers.seed.set = -1'
state: present
- name: Do not save uploaded Torrents
lineinfile:
path: '/opt/appdata/{{pgrole}}/rutorrent/settings/config.php'
regexp: '\$saveUploadedTorrents\s*=.*'
line: '$saveUploadedTorrents = false;'
state: present
- name: overwrite uploaded Torrents
lineinfile:
path: '/opt/appdata/{{pgrole}}/rutorrent/settings/config.php'
regexp: '\$overwriteUploadedTorrents\s*=.*'
line: '$overwriteUploadedTorrents = true;'
state: present
when: not rccheck.stat.exists
- name: Restart Docker Container
docker_container:
name: '{{pgrole}}'
state: started