diff --git a/roles/network/templates/gateway/iiab-gen-iptables b/roles/network/templates/gateway/iiab-gen-iptables index 812fe1b39..fdd91f56d 100755 --- a/roles/network/templates/gateway/iiab-gen-iptables +++ b/roles/network/templates/gateway/iiab-gen-iptables @@ -58,6 +58,8 @@ calibre_port={{ calibre_port }} kiwix_port={{ kiwix_port }} kalite_server_port={{ kalite_server_port }} kolibri_http_port={{ kolibri_http_port }} +transmission_http_port={{ transmission_http_port }} +transmission_peer_port={{ transmission_peer_port }} sugarizer_port={{ sugarizer_port }} block_DNS={{ block_DNS }} captive_portal_enabled={{ captive_portal_enabled }} @@ -94,6 +96,8 @@ if [ "$services_externally_visible" == "True" ]; then $IPTABLES -A INPUT -p tcp --dport $kolibri_http_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $calibre_port -m state --state NEW -i $wan -j ACCEPT $IPTABLES -A INPUT -p tcp --dport $sugarizer_port -m state --state NEW -i $wan -j ACCEPT + $IPTABLES -A INPUT -p tcp --dport $transmission_http_port -m state --state NEW -i $wan -j ACCEPT + $IPTABLES -A INPUT -p tcp --dport $transmission_peer_port -m state --state NEW -i $wan -j ACCEPT fi if [ "$iiab_gateway_enabled" == "True" ]; then diff --git a/roles/transmission/README.rst b/roles/transmission/README.rst new file mode 100644 index 000000000..12029afea --- /dev/null +++ b/roles/transmission/README.rst @@ -0,0 +1,62 @@ +=================== +Transmission README +=================== + +Transmission is a set of lightweight BitTorrent clients (in GUI, CLI and daemon form). All these incarnations feature a very simple and intuitive interface, on top on an efficient, cross-platform back-end. + +Transmission is intended to download KA Lite content to IIAB, from places like http://pantry.learningequality.org/downloads/ka-lite/0.17/content/ -- and also to seed it, in assistance of others. + +Once the packages are downloaded, please verify the content before copying it (carefully) to KA Lite content directory: /library/ka-lite/content + +Caution +------- + +Usage of Transmission consumes significant Internet data and system resources. +Caveat emptor! (That's Latin for "Buyer Beware") + +Access +------ + +Login to Transmission's web interface http://box:9091 using administrative account: + +Username: Admin +Password: changeme + +Alternatively, you can type 'transmission-remote' at the command-line. + +Configuration +------------- + +You can configure Transmission using its web interface http://box:9091 + +You can also edit Transmission settings in '/etc/transmission-daemon/settings.json'. Before you start editing the +'settings.json' file, please ensure that transmission-daemon.service is stopped: + +$ sudo systemctl stop transmission-daemon.service + +$ sudo nano /etc/transmission-daemon/settings.json + +Adding torrents +--------------- + +Transmission can facilitate provisioning your IIAB, by adding KA Lite content from places like: http://pantry.learningequality.org/downloads/ka-lite/0.17/content/ + +You can also download other torrents using Transmission's web interface, or by typing 'transmission-remote' at the command-line. + +$ transmission-remote -a + +Known Issues +------------ + +* Default Transmission user/group (See https://github.com/transmission/transmission/issues/537). Currently you need to set these "transmission_user" and "transmission_group" variables. Check their values in transmission-daemon's systemd unit file: lib/systemd/system/transmission-daemon.service + +* Random Ports: Currently it is not possible to use random ports in the range 49152-65535. It is difficult to open multiple ports in IIAB's iptables-based firewall. + +Troubleshooting +--------------- + +Please check if the transmission daemon is running: + +$ sudo systemctl status transmission-daemon.service + +Check that Transmission's settings are correct in: /etc/transmission-daemon/settings.json diff --git a/roles/transmission/defaults/main.yml b/roles/transmission/defaults/main.yml new file mode 100644 index 000000000..ba9c6929e --- /dev/null +++ b/roles/transmission/defaults/main.yml @@ -0,0 +1,33 @@ +# The values here are defaults. +# To override them edit /etc/iiab/local_vars.yml + +# Installation Variables +transmission_install: False +transmission_enabled: False + +# Transmission default download directory. +transmission_download_dir: "/library/transmission/" + +# Transmission default web and bittorrent ports http://box:9091/transmission/ +transmission_http_port: 9091 +transmission_peer_port: 51413 +transmission_url : "/transmission/" +transmission_user: debian-transmission +transmission_group: root + +# Provision Transmission with default torrents from http://pantry.learningequality.org/downloads/ka-lite/0.17/content/ +transmission_provision: True +transmission_kalite_version: 0.17 +# Uncomment to enable a language to download. +transmission_kalite_languages: + - english + #- french + #- hindi + #- portugal-portuguese + #- brazilian-portuguese + #- spanish + #- swahili + +# Transmission administration account +transmission_username: Admin +transmission_password: changeme diff --git a/roles/transmission/tasks/main.yml b/roles/transmission/tasks/main.yml new file mode 100644 index 000000000..a71f831ee --- /dev/null +++ b/roles/transmission/tasks/main.yml @@ -0,0 +1,73 @@ +--- +- name: Create Transmission download directory + file: + path: "{{ item }}" + owner: "{{ transmission_user }}" + group: "{{ transmission_group }}" + mode: 0755 + state: directory + with_items: + - "{{ transmission_download_dir }}" + +- name: Install Transmission daemon and its command line tools. + package: + name: "{{ item }}" + state: present + with_items: + - transmission-daemon + - transmission-cli + +- name: Stop Transmission daemon before modifying its settings. + service: + name: transmission-daemon + state: stopped + +- name: Create the transmission-daemon settings + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: "{{ item.mode }}" + owner: "{{ transmission_user }}" + group: "{{ transmission_group }}" + with_items: + - { src: 'settings.json.j2', dest: '/etc/transmission-daemon/settings.json', mode: '0644' } + +- name: Start Transmission daemon. + service: + name: transmission-daemon + state: restarted + enabled: yes + when: transmission_enabled + +- name: Add ka-lite torrents to transmission daemon. + shell: /usr/bin/transmission-remote -a http://pantry.learningequality.org/downloads/ka-lite/{{ transmission_kalite_version }}/content/ka-lite-0.17-resized-videos-{{ item }}.torrent + with_items: "{{ transmission_kalite_languages }}" + ignore_errors: yes + when: transmission_provision + +- name: Disable Transmission daemon service. + service: + name: transmission-daemon + enabled: no + state: stopped + when: not transmission_enabled + +- name: Add transmission to list of services at /etc/iiab/iiab.ini + ini_file: + dest: "{{ service_filelist }}" + section: transmission + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: transmission + - option: description + value: '"Transmission is a set of lightweight BitTorrent clients (in GUI, CLI and daemon form)."' + - option: transmission_enabled + value: "{{ transmission_enabled }}" + - option: transmission_install + value: "{{ transmission_install }}" + - option: transmission_http_port + value: "{{ transmission_http_port }}" + - option: transmission_url + value: "{{ transmission_url }}" diff --git a/roles/transmission/templates/settings.json.j2 b/roles/transmission/templates/settings.json.j2 new file mode 100644 index 000000000..a7c31a1ee --- /dev/null +++ b/roles/transmission/templates/settings.json.j2 @@ -0,0 +1,73 @@ +{ + "alt-speed-down": 50, + "alt-speed-enabled": false, + "alt-speed-time-begin": 540, + "alt-speed-time-day": 127, + "alt-speed-time-enabled": false, + "alt-speed-time-end": 1020, + "alt-speed-up": 50, + "bind-address-ipv4": "0.0.0.0", + "bind-address-ipv6": "::", + "blocklist-enabled": false, + "blocklist-url": "http://www.example.com/blocklist", + "cache-size-mb": 4, + "dht-enabled": true, + "download-dir": "{{ transmission_download_dir }}", + "download-limit": 100, + "download-limit-enabled": 0, + "download-queue-enabled": true, + "download-queue-size": 5, + "encryption": 1, + "idle-seeding-limit": 30, + "idle-seeding-limit-enabled": false, + "incomplete-dir": "/var/lib/transmission-daemon/Downloads", + "incomplete-dir-enabled": false, + "lpd-enabled": false, + "max-peers-global": 200, + "message-level": 1, + "peer-congestion-algorithm": "", + "peer-id-ttl-hours": 6, + "peer-limit-global": 200, + "peer-limit-per-torrent": 50, + "peer-port": {{ transmission_peer_port }}, + "peer-port-random-high": 65535, + "peer-port-random-low": 49152, + "peer-port-random-on-start": false, + "peer-socket-tos": "default", + "pex-enabled": true, + "port-forwarding-enabled": false, + "preallocation": 1, + "prefetch-enabled": true, + "queue-stalled-enabled": true, + "queue-stalled-minutes": 30, + "ratio-limit": 2, + "ratio-limit-enabled": false, + "rename-partial-files": true, + "rpc-authentication-required": false, + "rpc-bind-address": "0.0.0.0", + "rpc-enabled": true, + "rpc-host-whitelist": "", + "rpc-host-whitelist-enabled": true, + "rpc-password": "{{ transmission_password }}", + "rpc-port": {{ transmission_http_port }}, + "rpc-url": "{{ transmission_url }}", + "rpc-username": "{{ transmission_username }}", + "rpc-whitelist": "127.0.0.1,192.168.*.*", + "rpc-whitelist-enabled": true, + "scrape-paused-torrents-enabled": true, + "script-torrent-done-enabled": false, + "script-torrent-done-filename": "", + "seed-queue-enabled": false, + "seed-queue-size": 10, + "speed-limit-down": 100, + "speed-limit-down-enabled": false, + "speed-limit-up": 100, + "speed-limit-up-enabled": false, + "start-added-torrents": true, + "trash-original-torrent-files": false, + "umask": 18, + "upload-limit": 100, + "upload-limit-enabled": 0, + "upload-slots-per-torrent": 14, + "utp-enabled": true +}