Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add role: transmissionx #273

Merged
merged 19 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Community Repository for Unofficial Cloudbox Add-ons
- **subsonic**
- **[telly](../../wiki/Telly)**
- **[transmissionvpn](https://github.com/haugene/docker-transmission-openvpn)**
- **[transmissionx](../../wiki/transmissionx)** - lightweight torrent client - role to create multiple roles (default is one)
- **ubooquity** - comics server and online reader (ubooquity.your.server/ubooquity for main page / your.ip:2203/ubooquity/admin for admin)
- **[wallabag](https://wallabag.org/en)** 0 Wallabag role (default u/p wallabag/wallabag) - Save and classify websites and articles.
- **[Wordpress](../../wiki/Wordpress)** - Wordpress deployment
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ environment:
tdarr
thelounge
transmissionvpn
transmissionx
ubooquity
unifi
unmanic
Expand Down
1 change: 1 addition & 0 deletions community.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
- { role: telly, tags: ['telly'] }
- { role: thelounge, tags: ['thelounge'] }
- { role: transmissionvpn, tags: ['transmissionvpn'] }
- { role: transmissionx, tags: ['transmissionx'] }
- { role: ubooquity, tags: ['ubooquity'] }
- { role: unifi, tags: ['unifi'] }
- { role: unmanic, tags: ['unmanic'] }
Expand Down
2 changes: 2 additions & 0 deletions defaults/settings.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ transmissionvpn:
vpn_pass: your_vpn_password
vpn_prov: NORDVPN
vpn_endpoint: Netherlands.ovpn
transmissionx:
roles: [""]
unifi:
port: 8080
33 changes: 33 additions & 0 deletions roles/transmissionx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#########################################################################
# Title: Community: TransmissionX #
# Author(s): giosann #
# URL: https://github.com/Cloudbox/Community #
# Docker Image(s): linuxserver/trasmission #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: "Gather list of transmissionx Docker containers"
shell: "docker ps -a --format '{{ '{{' }} .Names{{ '}}' }}' --filter label=com.github.cloudbox.community=transmissionx | xargs echo -n"
register: cloudbox_community_transmissionx
ignore_errors: yes

- name: "Stop all transmissionx Docker containers"
shell: "docker stop {{ cloudbox_community_transmissionx.stdout }}"
ignore_errors: yes
when: (cloudbox_community_transmissionx.stdout | trim | length > 0)

- name: "Remove all transmissionx Docker containers"
shell: "docker rm {{ cloudbox_community_transmissionx.stdout }}"
ignore_errors: yes
when: (cloudbox_community_transmissionx.stdout | trim | length > 0)

- name: "Execute transmissionx roles"
include_tasks: template.yml
vars:
rolename: "{{ role }}"
with_items: "{{ transmissionx.roles }}"
loop_control:
loop_var: role
37 changes: 37 additions & 0 deletions roles/transmissionx/tasks/settings/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#########################################################################
# Title: transmissionx: Sttings Tasks #
# Author(s): giosann #
# URL: https://github.com/Cloudbox/Community #
# Docker Image(s): linuxserver/trasmission #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
## Checks

- name: Settings | Wait for 'settings.json' to be created
wait_for:
path: "/opt/transmission{{ rolename }}/settings.json"
state: present

- name: Settings | Wait for 10 seconds before stopping transmissionx container
wait_for:
timeout: 10

- name: Settings | Stop container
docker_container:
name: transmission{{ rolename }}
state: stopped

## transmissionx Static Settings Tasks

- name: Settings | transmissionx Static Settings Tasks
include_tasks: "static.yml"
when: (not settings_json.stat.exists)

- name: Settings | Start container
docker_container:
name: transmission{{ rolename }}
state: started
84 changes: 84 additions & 0 deletions roles/transmissionx/tasks/settings/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#########################################################################
# Title: ruTorrent - Static Settings Tasks #
# Author(s): l3uddz, desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# Docker Image: horjulf/rutorrent-autodl #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
## rtorrent.rc

# Disable DHT - i.e. disables trackerless torrents.
- name: Settings | Static | Disable DHT
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"dht\-enabled\"\:.*'
line: ' "dht-enabled": false,'
state: present

# Disable Peer exchange (PEX) - i.e. allows torrents marked private, only.
- name: Settings | Static | Disable PEX
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"pex\-enabled\"\:.*'
line: ' "pex-enabled": false,'
state: present

# Change default download directory - change download directory for sonarr/radarr compatibility.
- name: Settings | Static | Change download-dir
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"download\-dir\"\:.*'
line: ' "download-dir": "/downloads/torrents/transmission{{ rolename }}/complete",'
state: present

# Change default incomplete directory
- name: Settings | Static | Change incomplete-dir
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"incomplete\-dir\"\:.*'
line: ' "incomplete-dir": "/downloads/torrents/transmission{{ rolename }}/incomplete",'
state: present

# Disable incomplete directory
- name: Settings | Static | Disable incomplete-dir
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"incomplete\-dir\-enabled\"\:.*'
line: ' "incomplete-dir-enabled": false,'
state: present

# Maximum number of simultaneous upload slots per torrent
- name: Settings | Static | Set upload-slots-per-torrent
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"upload\-slots\-per\-torrent\"\:.*'
line: ' "upload-slots-per-torrent": 50,'
state: present

# Maximum number of global peers
- name: Settings | Static | Set peer-limit-global
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"peer\-limit\-global\"\:.*'
line: ' "peer-limit-global": 1024,'
state: present

# Allocate disk space
- name: Settings | Static | Disable preallocation
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"preallocation\"\:.*'
line: ' "preallocation": 0,'
state: present

# Allocate disk space
- name: Settings | Static | Set cache-size-mb
lineinfile:
path: "/opt/transmission{{ rolename }}/settings.json"
regexp: '^\s*\"cache\-size\-mb\"\:.*'
line: ' "cache-size-mb": 20,'
state: present
85 changes: 85 additions & 0 deletions roles/transmissionx/tasks/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#########################################################################
# Title: Community: TransmissionX | Template #
# Author(s): giosann #
# URL: https://github.com/Cloudbox/Community #
# Docker Image(s): linuxserver/trasmission #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: "Install named transmission role"
debug:
msg: "Installing {{ rolename }}"

- name: "Set DNS Record on CloudFlare"
include_role:
name: cloudflare-dns
vars:
record: "transmission{{ rolename }}"
when: cloudflare_enabled

- name: Create transmissionx directories
file: "path={{ item }} state=directory mode=0775 owner={{ user.name }} group={{ user.name }}"
with_items:
- "/opt/transmission{{ rolename }}"

- name: Create new downloads directories
file: "path={{ item }} state=directory mode=0775 owner={{ user.name }} group={{ user.name }} recurse=yes"
with_items:
- "{{ downloads.torrents }}"
- "{{ downloads.torrents }}/transmission{{ rolename }}"
- "{{ downloads.torrents }}/transmission{{ rolename }}/complete"
- "{{ downloads.torrents }}/transmission{{ rolename }}/incomplete"
- "{{ downloads.torrents }}/transmission{{ rolename }}/watch"
when: (torrents_downloads_path is defined)|default(false)

- name: Check if settings.json exists
stat:
path: "/opt/transmission{{ rolename }}/settings.json"
register: settings_json

- name: Set default_volumes variable
set_fact:
default_volumes:
- "/mnt:/mnt"
- "/opt/transmission{{ rolename }}:/config"

- name: Create and start container
docker_container:
name: "transmission{{ rolename }}"
image: "linuxserver/transmission"
pull: yes
env:
TZ: "{{ tz }}"
PUID: "{{ uid }}"
PGID: "{{ gid }}"
VIRTUAL_HOST: "transmission{{ rolename }}.{{ user.domain }}"
VIRTUAL_PORT: "9091"
LETSENCRYPT_HOST: "transmission{{ rolename }}.{{ user.domain }}"
LETSENCRYPT_EMAIL: "{{ user.email }}"
UMASK_SET: "002"
TRANSMISSION_WEB_HOME: "/transmission-web-control/"
USER: "{{ user.name }}"
PASS: "{{ user.pass }}"

volumes: "{{ default_volumes + torrents_downloads_path|default([]) }}"
labels:
"com.github.cloudbox.cloudbox_managed": "true"
"com.github.cloudbox.community": "transmissionx"
networks:
- name: cloudbox
aliases:
- "transmission{{ rolename }}"
purge_networks: yes
restart_policy: always
state: started

- name: transmissionx Settings Tasks
include_tasks: "settings/main.yml"
vars:
rolename: "{{ role }}"
loop_control:
loop_var: role
when: (not continuous_integration)