diff --git a/Dockerfile b/Dockerfile index e749218..6258774 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ # Transmission and OpenVPN # -# Version 1.0 +# Version 1.1 FROM ubuntu:14.04 MAINTAINER Kristian Haugene VOLUME /data +VOLUME /config # Update packages and install software RUN apt-get update \ @@ -17,16 +18,8 @@ RUN apt-get update \ && curl -L https://github.com/jwilder/dockerize/releases/download/v0.0.2/dockerize-linux-amd64-v0.0.2.tar.gz | tar -C /usr/local/bin -xzv # Add configuration and scripts -ADD piaconfig/* /etc/openvpn/ -ADD piaconfig/ca.crt /etc/openvpn/ca.crt -ADD piaconfig/crl.pem /etc/openvpn/crl.pem -ADD transmission/defaultSettings.tmpl /etc/transmission-daemon/settings.tmpl -ADD transmission/updateTransmissionPort.sh /etc/transmission-daemon/updatePort.sh -ADD transmission/periodicUpdates.sh /etc/transmission-daemon/periodicUpdates.sh -ADD transmission/run.sh /etc/transmission-daemon/start.sh -ADD transmission/runUpdates.sh /etc/transmission-daemon/startPortUpdates.sh -ADD transmission/down.sh /etc/transmission-daemon/stop.sh -ADD runOpenVpn.sh /etc/openvpn/start.sh +ADD openvpn/* /etc/openvpn/ +ADD transmission/* /etc/transmission-daemon/ ENV PIA_USERNAME=**None** \ PIA_PASSWORD=**None** \ @@ -103,6 +96,6 @@ ENV PIA_USERNAME=**None** \ "TRANSMISSION_WATCH_DIR_ENABLED=true" \ RESOLV_OVERRIDE=**None** -# Expose port and run. Use baseimage-docker's init system +# Expose port and run EXPOSE 9091 CMD ["/etc/openvpn/start.sh"] diff --git a/README.md b/README.md index f7f0521..7f1a13d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Private Internet Access OpenVPN - Transmission === This Docker container lets you run Transmission with WebUI while connecting to PIA VPN. It updates Transmission hourly with assigned open port from PIA. Please read the instructions below. -# Run container from Docker registry +## Run container from Docker registry The container is available from the Docker registry and this is the simplest way to get it. To run the container use this command: ``` @@ -30,26 +30,19 @@ As you can see, the container expects a data volume to be mounted. It is used fo The only mandatory configuration is to set two environment variables for your PIA username and password. You must set the environment variables `PIA_USERNAME` and `PIA_PASSWORD` to your login credentials. The container will connect to the Private Internet Access VPN servers in Netherlands by default. -NB: Instructions on how to use your own Transmission settings, and how to connect to the WebUI, is further down in the README. - -## Required environment options +### Required environment options | Variable | Function | Example | |----------|----------|-------| |`PIA_USERNAME`|Your login username for PIA|`PIA_USERNAME=asdf`| |`PIA_PASSWORD`|Your login password for PIA|`PIA_PASSWORD=asdf`| -## Network configuration options +### Network configuration options | Variable | Function | Example | |----------|----------|-------| |`OPEN_VPN_CONFIG` | Sets the PIA endpoint to connect to. | `OPEN_VPN_CONFIG=UK Southampton`| |`RESOLV_OVERRIDE` | The value of this variable will be written to `/etc/resolv.conf`. | `RESOLV_OVERRIDE=nameserver 8.8.8.8\nnameserver 8.8.4.4\n`| -## Storage options -| Variable | Function | Example | -|----------|----------|-------| -|`KEEP_TRANSMISSION_STATE`|If set, persists transmission data to your /data mount point. Keeps state between restarts. Delete the folder to disable this later. |`KEEP_TRANSMISSION_STATE=YES`| - -## Transmission configuration options +### Transmission configuration options You may override transmission options by setting the appropriate environment variable. @@ -64,7 +57,9 @@ The environment variables are the same name as used in the transmission settings As you can see the variables are prefixed with `TRANSMISSION_`, the variable is capitalized, and `-` is converted to `_`. -# Building the container yourself +PS: `TRANSMISSION_BIND_ADDRESS_IPV4` will be overridden to the IP assigned to tunnel interface by PIA. This is to prevent leaking of the host IP. + +## Building the container yourself To build this container, clone the repository and cd into it. ### Build it: @@ -84,7 +79,7 @@ $ docker run --privileged -d \ As described in the "Run container from Docker registry" section, this will start a container with default settings. This means that you should have the folders "completed, incomplete and watch" in /your/storage/path, and pia-credentials.txt in /your/config/path. -### Access the WebUI +## Access the WebUI But what's going on? My http://my-host:9091 isn't responding? This is because the VPN is active, and since docker is running in a different ip range than your client the response to your request will be treated as "non-local" traffic and therefore be routed out through the VPN interface. @@ -113,7 +108,7 @@ http { Your Transmission WebUI should now be avaliable at "your.host.ip.addr:8080/transmission/web/". Change the port in the docker run command if 8080 is not suitable for you. -### What if I want to run the container interactively. +## What if I want to run the container interactively. If you want do have access inside the container while running you have two choices. To have a look inside an already running container, use docker exec to get a terminal inside the container. ``` @@ -129,3 +124,7 @@ $ docker run --privileged -it transmission-openvpn bash ``` From there you can start the service yourself, or do whatever (probably developer-related) you came to do. + +## Controlling Transmission remotely +The container exposes /config as a volume. This is the directory where the supplied transmission and PIA credentials will be stored. If you have transmission authentication enabled and want scripts in another container to access and control the transmission-daemon, this can be a handy way to access the credentials. +For example, another container may pause or restrict transmission speeds while the server is streaming video. diff --git a/piaconfig/AU Melbourne.ovpn b/openvpn/AU Melbourne.ovpn similarity index 97% rename from piaconfig/AU Melbourne.ovpn rename to openvpn/AU Melbourne.ovpn index b2be48e..a32dffa 100644 --- a/piaconfig/AU Melbourne.ovpn +++ b/openvpn/AU Melbourne.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote aus-melbourne.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/AU Sydney.ovpn b/openvpn/AU Sydney.ovpn similarity index 97% rename from piaconfig/AU Sydney.ovpn rename to openvpn/AU Sydney.ovpn index 5106144..04fb526 100644 --- a/piaconfig/AU Sydney.ovpn +++ b/openvpn/AU Sydney.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote aus.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/CA North York.ovpn b/openvpn/CA North York.ovpn similarity index 97% rename from piaconfig/CA North York.ovpn rename to openvpn/CA North York.ovpn index 80853f2..491482e 100644 --- a/piaconfig/CA North York.ovpn +++ b/openvpn/CA North York.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote ca.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/CA Toronto.ovpn b/openvpn/CA Toronto.ovpn similarity index 97% rename from piaconfig/CA Toronto.ovpn rename to openvpn/CA Toronto.ovpn index 7baeb4b..b52fa62 100644 --- a/piaconfig/CA Toronto.ovpn +++ b/openvpn/CA Toronto.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote ca-toronto.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/France.ovpn b/openvpn/France.ovpn similarity index 97% rename from piaconfig/France.ovpn rename to openvpn/France.ovpn index 140c3e9..b311bf0 100644 --- a/piaconfig/France.ovpn +++ b/openvpn/France.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote france.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Germany.ovpn b/openvpn/Germany.ovpn similarity index 97% rename from piaconfig/Germany.ovpn rename to openvpn/Germany.ovpn index fa1cce7..c496a73 100644 --- a/piaconfig/Germany.ovpn +++ b/openvpn/Germany.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote germany.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Hong Kong.ovpn b/openvpn/Hong Kong.ovpn similarity index 97% rename from piaconfig/Hong Kong.ovpn rename to openvpn/Hong Kong.ovpn index 299f984..328cfbf 100644 --- a/piaconfig/Hong Kong.ovpn +++ b/openvpn/Hong Kong.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote hk.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Israel.ovpn b/openvpn/Israel.ovpn similarity index 97% rename from piaconfig/Israel.ovpn rename to openvpn/Israel.ovpn index bcf0d76..7a617e3 100644 --- a/piaconfig/Israel.ovpn +++ b/openvpn/Israel.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote israel.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Japan.ovpn b/openvpn/Japan.ovpn similarity index 97% rename from piaconfig/Japan.ovpn rename to openvpn/Japan.ovpn index 2a1d44e..e3a8c1b 100644 --- a/piaconfig/Japan.ovpn +++ b/openvpn/Japan.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote japan.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Mexico.ovpn b/openvpn/Mexico.ovpn similarity index 97% rename from piaconfig/Mexico.ovpn rename to openvpn/Mexico.ovpn index 7199dd3..e2498dd 100644 --- a/piaconfig/Mexico.ovpn +++ b/openvpn/Mexico.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote mexico.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Netherlands.ovpn b/openvpn/Netherlands.ovpn similarity index 97% rename from piaconfig/Netherlands.ovpn rename to openvpn/Netherlands.ovpn index 7293b2a..4875fca 100644 --- a/piaconfig/Netherlands.ovpn +++ b/openvpn/Netherlands.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote nl.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Romania.ovpn b/openvpn/Romania.ovpn similarity index 97% rename from piaconfig/Romania.ovpn rename to openvpn/Romania.ovpn index 15e4d3f..5da65fd 100644 --- a/piaconfig/Romania.ovpn +++ b/openvpn/Romania.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote ro.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Russia.ovpn b/openvpn/Russia.ovpn similarity index 97% rename from piaconfig/Russia.ovpn rename to openvpn/Russia.ovpn index 1e885d6..106f565 100644 --- a/piaconfig/Russia.ovpn +++ b/openvpn/Russia.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote russia.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Singapore.ovpn b/openvpn/Singapore.ovpn similarity index 97% rename from piaconfig/Singapore.ovpn rename to openvpn/Singapore.ovpn index 15f14ff..5cd195b 100644 --- a/piaconfig/Singapore.ovpn +++ b/openvpn/Singapore.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote sg.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Sweden.ovpn b/openvpn/Sweden.ovpn similarity index 97% rename from piaconfig/Sweden.ovpn rename to openvpn/Sweden.ovpn index cd8a963..9129a59 100644 --- a/piaconfig/Sweden.ovpn +++ b/openvpn/Sweden.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote sweden.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/Switzerland.ovpn b/openvpn/Switzerland.ovpn similarity index 97% rename from piaconfig/Switzerland.ovpn rename to openvpn/Switzerland.ovpn index 98bcef0..8113f20 100644 --- a/piaconfig/Switzerland.ovpn +++ b/openvpn/Switzerland.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote swiss.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/UK London.ovpn b/openvpn/UK London.ovpn similarity index 97% rename from piaconfig/UK London.ovpn rename to openvpn/UK London.ovpn index ed5ceb5..1c43b4d 100644 --- a/piaconfig/UK London.ovpn +++ b/openvpn/UK London.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote uk-london.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/UK Southampton.ovpn b/openvpn/UK Southampton.ovpn similarity index 97% rename from piaconfig/UK Southampton.ovpn rename to openvpn/UK Southampton.ovpn index e0c426a..a668641 100644 --- a/piaconfig/UK Southampton.ovpn +++ b/openvpn/UK Southampton.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote uk-southampton.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US California.ovpn b/openvpn/US California.ovpn similarity index 97% rename from piaconfig/US California.ovpn rename to openvpn/US California.ovpn index 907d10c..1b72cbb 100644 --- a/piaconfig/US California.ovpn +++ b/openvpn/US California.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-california.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US East.ovpn b/openvpn/US East.ovpn similarity index 97% rename from piaconfig/US East.ovpn rename to openvpn/US East.ovpn index c67929f..368eacd 100644 --- a/piaconfig/US East.ovpn +++ b/openvpn/US East.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-east.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US Florida.ovpn b/openvpn/US Florida.ovpn similarity index 97% rename from piaconfig/US Florida.ovpn rename to openvpn/US Florida.ovpn index b593738..2af9e4e 100644 --- a/piaconfig/US Florida.ovpn +++ b/openvpn/US Florida.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-florida.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US Midwest.ovpn b/openvpn/US Midwest.ovpn similarity index 97% rename from piaconfig/US Midwest.ovpn rename to openvpn/US Midwest.ovpn index ac68135..446357f 100644 --- a/piaconfig/US Midwest.ovpn +++ b/openvpn/US Midwest.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-midwest.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US Seattle.ovpn b/openvpn/US Seattle.ovpn similarity index 97% rename from piaconfig/US Seattle.ovpn rename to openvpn/US Seattle.ovpn index 127dc4e..c428b8e 100644 --- a/piaconfig/US Seattle.ovpn +++ b/openvpn/US Seattle.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-seattle.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US Silicon Valley.ovpn b/openvpn/US Silicon Valley.ovpn similarity index 97% rename from piaconfig/US Silicon Valley.ovpn rename to openvpn/US Silicon Valley.ovpn index 92eb68c..71fdb84 100644 --- a/piaconfig/US Silicon Valley.ovpn +++ b/openvpn/US Silicon Valley.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-siliconvalley.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US Texas.ovpn b/openvpn/US Texas.ovpn similarity index 97% rename from piaconfig/US Texas.ovpn rename to openvpn/US Texas.ovpn index 289a73e..470cb08 100644 --- a/piaconfig/US Texas.ovpn +++ b/openvpn/US Texas.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-texas.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/US West.ovpn b/openvpn/US West.ovpn similarity index 97% rename from piaconfig/US West.ovpn rename to openvpn/US West.ovpn index d09b1e8..a674271 100644 --- a/piaconfig/US West.ovpn +++ b/openvpn/US West.ovpn @@ -1,5 +1,5 @@ client -dev tun +dev tun0 proto udp remote us-west.privateinternetaccess.com 1194 resolv-retry infinite diff --git a/piaconfig/ca.crt b/openvpn/ca.crt similarity index 100% rename from piaconfig/ca.crt rename to openvpn/ca.crt diff --git a/piaconfig/crl.pem b/openvpn/crl.pem similarity index 100% rename from piaconfig/crl.pem rename to openvpn/crl.pem diff --git a/runOpenVpn.sh b/openvpn/start.sh similarity index 80% rename from runOpenVpn.sh rename to openvpn/start.sh index 8909c2a..211c1b3 100755 --- a/runOpenVpn.sh +++ b/openvpn/start.sh @@ -38,13 +38,7 @@ fi echo $TRANSMISSION_RPC_USERNAME > /config/transmission-credentials.txt echo $TRANSMISSION_RPC_PASSWORD >> /config/transmission-credentials.txt - -if [ ! -z ${KEEP_TRANSMISSION_STATE} ] -then - mkdir -p /data/transmission-data/ - dockerize -template /etc/transmission-daemon/settings.tmpl:/data/transmission-data/settings.json true -else - dockerize -template /etc/transmission-daemon/settings.tmpl:/etc/transmission-daemon/settings.json true -fi +# Persist transmission settings for use by transmission-daemon +dockerize -template /etc/transmission-daemon/environment-variables.tmpl:/etc/transmission-daemon/environment-variables.sh /bin/true exec openvpn --config "$OPEN_VPN_CONFIG" diff --git a/transmission/environment-variables.tmpl b/transmission/environment-variables.tmpl new file mode 100644 index 0000000..5959f7e --- /dev/null +++ b/transmission/environment-variables.tmpl @@ -0,0 +1,74 @@ +#! /bin/sh + +export TRANSMISSION_ALT_SPEED_DOWN={{ .Env.TRANSMISSION_ALT_SPEED_DOWN }} +export TRANSMISSION_ALT_SPEED_ENABLED={{ .Env.TRANSMISSION_ALT_SPEED_ENABLED }} +export TRANSMISSION_ALT_SPEED_TIME_BEGIN={{ .Env.TRANSMISSION_ALT_SPEED_TIME_BEGIN }} +export TRANSMISSION_ALT_SPEED_TIME_DAY={{ .Env.TRANSMISSION_ALT_SPEED_TIME_DAY }} +export TRANSMISSION_ALT_SPEED_TIME_ENABLED={{ .Env.TRANSMISSION_ALT_SPEED_TIME_ENABLED }} +export TRANSMISSION_ALT_SPEED_TIME_END={{ .Env.TRANSMISSION_ALT_SPEED_TIME_END }} +export TRANSMISSION_ALT_SPEED_UP={{ .Env.TRANSMISSION_ALT_SPEED_UP }} +export TRANSMISSION_BIND_ADDRESS_IPV4={{ .Env.TRANSMISSION_BIND_ADDRESS_IPV4 }} +export TRANSMISSION_BIND_ADDRESS_IPV6={{ .Env.TRANSMISSION_BIND_ADDRESS_IPV6 }} +export TRANSMISSION_BLOCKLIST_ENABLED={{ .Env.TRANSMISSION_BLOCKLIST_ENABLED }} +export TRANSMISSION_BLOCKLIST_URL={{ .Env.TRANSMISSION_BLOCKLIST_URL }} +export TRANSMISSION_CACHE_SIZE_MB={{ .Env.TRANSMISSION_CACHE_SIZE_MB }} +export TRANSMISSION_DHT_ENABLED={{ .Env.TRANSMISSION_DHT_ENABLED }} +export TRANSMISSION_DOWNLOAD_DIR={{ .Env.TRANSMISSION_DOWNLOAD_DIR }} +export TRANSMISSION_DOWNLOAD_LIMIT={{ .Env.TRANSMISSION_DOWNLOAD_LIMIT }} +export TRANSMISSION_DOWNLOAD_LIMIT_ENABLED={{ .Env.TRANSMISSION_DOWNLOAD_LIMIT_ENABLED }} +export TRANSMISSION_DOWNLOAD_QUEUE_ENABLED={{ .Env.TRANSMISSION_DOWNLOAD_QUEUE_ENABLED }} +export TRANSMISSION_DOWNLOAD_QUEUE_SIZE={{ .Env.TRANSMISSION_DOWNLOAD_QUEUE_SIZE }} +export TRANSMISSION_ENCRYPTION={{ .Env.TRANSMISSION_ENCRYPTION }} +export TRANSMISSION_IDLE_SEEDING_LIMIT={{ .Env.TRANSMISSION_IDLE_SEEDING_LIMIT }} +export TRANSMISSION_IDLE_SEEDING_LIMIT_ENABLED={{ .Env.TRANSMISSION_IDLE_SEEDING_LIMIT_ENABLED }} +export TRANSMISSION_INCOMPLETE_DIR={{ .Env.TRANSMISSION_INCOMPLETE_DIR }} +export TRANSMISSION_INCOMPLETE_DIR_ENABLED={{ .Env.TRANSMISSION_INCOMPLETE_DIR_ENABLED }} +export TRANSMISSION_LPD_ENABLED={{ .Env.TRANSMISSION_LPD_ENABLED }} +export TRANSMISSION_MAX_PEERS_GLOBAL={{ .Env.TRANSMISSION_MAX_PEERS_GLOBAL }} +export TRANSMISSION_MESSAGE_LEVEL={{ .Env.TRANSMISSION_MESSAGE_LEVEL }} +export TRANSMISSION_PEER_CONGESTION_ALGORITHM={{ .Env.TRANSMISSION_PEER_CONGESTION_ALGORITHM }} +export TRANSMISSION_PEER_ID_TTL_HOURS={{ .Env.TRANSMISSION_PEER_ID_TTL_HOURS }} +export TRANSMISSION_PEER_LIMIT_GLOBAL={{ .Env.TRANSMISSION_PEER_LIMIT_GLOBAL }} +export TRANSMISSION_PEER_LIMIT_PER_TORRENT={{ .Env.TRANSMISSION_PEER_LIMIT_PER_TORRENT }} +export TRANSMISSION_PEER_PORT={{ .Env.TRANSMISSION_PEER_PORT }} +export TRANSMISSION_PEER_PORT_RANDOM_HIGH={{ .Env.TRANSMISSION_PEER_PORT_RANDOM_HIGH }} +export TRANSMISSION_PEER_PORT_RANDOM_LOW={{ .Env.TRANSMISSION_PEER_PORT_RANDOM_LOW }} +export TRANSMISSION_PEER_PORT_RANDOM_ON_START={{ .Env.TRANSMISSION_PEER_PORT_RANDOM_ON_START }} +export TRANSMISSION_PEER_SOCKET_TOS={{ .Env.TRANSMISSION_PEER_SOCKET_TOS }} +export TRANSMISSION_PEX_ENABLED={{ .Env.TRANSMISSION_PEX_ENABLED }} +export TRANSMISSION_PORT_FORWARDING_ENABLED={{ .Env.TRANSMISSION_PORT_FORWARDING_ENABLED }} +export TRANSMISSION_PREALLOCATION={{ .Env.TRANSMISSION_PREALLOCATION }} +export TRANSMISSION_PREFETCH_ENABLED={{ .Env.TRANSMISSION_PREFETCH_ENABLED }} +export TRANSMISSION_QUEUE_STALLED_ENABLED={{ .Env.TRANSMISSION_QUEUE_STALLED_ENABLED }} +export TRANSMISSION_QUEUE_STALLED_MINUTES={{ .Env.TRANSMISSION_QUEUE_STALLED_MINUTES }} +export TRANSMISSION_RATIO_LIMIT={{ .Env.TRANSMISSION_RATIO_LIMIT }} +export TRANSMISSION_RATIO_LIMIT_ENABLED={{ .Env.TRANSMISSION_RATIO_LIMIT_ENABLED }} +export TRANSMISSION_RENAME_PARTIAL_FILES={{ .Env.TRANSMISSION_RENAME_PARTIAL_FILES }} +export TRANSMISSION_RPC_AUTHENTICATION_REQUIRED={{ .Env.TRANSMISSION_RPC_AUTHENTICATION_REQUIRED }} +export TRANSMISSION_RPC_BIND_ADDRESS={{ .Env.TRANSMISSION_RPC_BIND_ADDRESS }} +export TRANSMISSION_RPC_ENABLED={{ .Env.TRANSMISSION_RPC_ENABLED }} +export TRANSMISSION_RPC_PASSWORD={{ .Env.TRANSMISSION_RPC_PASSWORD }} +export TRANSMISSION_RPC_PORT={{ .Env.TRANSMISSION_RPC_PORT }} +export TRANSMISSION_RPC_URL={{ .Env.TRANSMISSION_RPC_URL }} +export TRANSMISSION_RPC_USERNAME={{ .Env.TRANSMISSION_RPC_USERNAME }} +export TRANSMISSION_RPC_WHITELIST={{ .Env.TRANSMISSION_RPC_WHITELIST }} +export TRANSMISSION_RPC_WHITELIST_ENABLED={{ .Env.TRANSMISSION_RPC_WHITELIST_ENABLED }} +export TRANSMISSION_SCRAPE_PAUSED_TORRENTS_ENABLED={{ .Env.TRANSMISSION_SCRAPE_PAUSED_TORRENTS_ENABLED }} +export TRANSMISSION_SCRIPT_TORRENT_DONE_ENABLED={{ .Env.TRANSMISSION_SCRIPT_TORRENT_DONE_ENABLED }} +export TRANSMISSION_SCRIPT_TORRENT_DONE_FILENAME={{ .Env.TRANSMISSION_SCRIPT_TORRENT_DONE_FILENAME }} +export TRANSMISSION_SEED_QUEUE_ENABLED={{ .Env.TRANSMISSION_SEED_QUEUE_ENABLED }} +export TRANSMISSION_SEED_QUEUE_SIZE={{ .Env.TRANSMISSION_SEED_QUEUE_SIZE }} +export TRANSMISSION_SPEED_LIMIT_DOWN={{ .Env.TRANSMISSION_SPEED_LIMIT_DOWN }} +export TRANSMISSION_SPEED_LIMIT_DOWN_ENABLED={{ .Env.TRANSMISSION_SPEED_LIMIT_DOWN_ENABLED }} +export TRANSMISSION_SPEED_LIMIT_UP={{ .Env.TRANSMISSION_SPEED_LIMIT_UP }} +export TRANSMISSION_SPEED_LIMIT_UP_ENABLED={{ .Env.TRANSMISSION_SPEED_LIMIT_UP_ENABLED }} +export TRANSMISSION_START_ADDED_TORRENTS={{ .Env.TRANSMISSION_START_ADDED_TORRENTS }} +export TRANSMISSION_TRASH_ORIGINAL_TORRENT_FILES={{ .Env.TRANSMISSION_TRASH_ORIGINAL_TORRENT_FILES }} +export TRANSMISSION_UMASK={{ .Env.TRANSMISSION_UMASK }} +export TRANSMISSION_UPLOAD_LIMIT={{ .Env.TRANSMISSION_UPLOAD_LIMIT }} +export TRANSMISSION_UPLOAD_LIMIT_ENABLED={{ .Env.TRANSMISSION_UPLOAD_LIMIT_ENABLED }} +export TRANSMISSION_UPLOAD_SLOTS_PER_TORRENT={{ .Env.TRANSMISSION_UPLOAD_SLOTS_PER_TORRENT }} +export TRANSMISSION_UTP_ENABLED={{ .Env.TRANSMISSION_UTP_ENABLED }} +export TRANSMISSION_WATCH_DIR={{ .Env.TRANSMISSION_WATCH_DIR }} +export TRANSMISSION_WATCH_DIR_ENABLED={{ .Env.TRANSMISSION_WATCH_DIR_ENABLED }} + diff --git a/transmission/periodicUpdates.sh b/transmission/periodicUpdates.sh index ffcd37a..2325b27 100755 --- a/transmission/periodicUpdates.sh +++ b/transmission/periodicUpdates.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh while [ 1 ] do diff --git a/transmission/run.sh b/transmission/run.sh deleted file mode 100755 index 59a25f9..0000000 --- a/transmission/run.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -if [ -f /data/transmission-data/settings.json ] -then - echo "STARTING TRANSMISSION: Using transmission-data subdirectory to your /data mount point to store state." - exec /usr/bin/transmission-daemon -g /data/transmission-data/ & -else - echo "STARTING TRANSMISSION: Storing state in container only." - exec /usr/bin/transmission-daemon -g /etc/transmission-daemon/ & -fi - -exec /etc/transmission-daemon/startPortUpdates.sh & - -echo "STARTED PORT UPDATER" diff --git a/transmission/runUpdates.sh b/transmission/runUpdates.sh deleted file mode 100755 index 5e9a023..0000000 --- a/transmission/runUpdates.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec /etc/transmission-daemon/periodicUpdates.sh diff --git a/transmission/defaultSettings.tmpl b/transmission/settings.tmpl similarity index 100% rename from transmission/defaultSettings.tmpl rename to transmission/settings.tmpl diff --git a/transmission/start.sh b/transmission/start.sh new file mode 100755 index 0000000..8c5e76f --- /dev/null +++ b/transmission/start.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Source our persisted env variables from container startup +. /etc/transmission-daemon/environment-variables.sh + +tun0ip=$(ifconfig tun0 | sed -n '2 p' | awk '{print $2}' | cut -d: -f2) +echo "Updating TRANSMISSION_BIND_ADDRESS_IPV4 to tun0 ip: ${tun0ip}" +export TRANSMISSION_BIND_ADDRESS_IPV4=${tun0ip} + +echo "Generating transmission settings.json from env variables" +dockerize -template /etc/transmission-daemon/settings.tmpl:/etc/transmission-daemon/settings.json /bin/true + +echo "STARTING TRANSMISSION" +exec /usr/bin/transmission-daemon -g /etc/transmission-daemon/ & + +echo "STARTING PORT UPDATER" +exec /etc/transmission-daemon/periodicUpdates.sh & + +echo "Transmission startup script complete." diff --git a/transmission/down.sh b/transmission/stop.sh similarity index 85% rename from transmission/down.sh rename to transmission/stop.sh index 0f9c4f4..36f6f51 100755 --- a/transmission/down.sh +++ b/transmission/stop.sh @@ -1,3 +1,3 @@ -#! /bin/bash +#! /bin/sh kill $(ps aux | grep transmission-daemon | grep -v grep | awk '{print $2}') diff --git a/transmission/updateTransmissionPort.sh b/transmission/updatePort.sh similarity index 84% rename from transmission/updateTransmissionPort.sh rename to transmission/updatePort.sh index f798ff1..dae3703 100755 --- a/transmission/updateTransmissionPort.sh +++ b/transmission/updatePort.sh @@ -1,4 +1,4 @@ -#/bin/bash +#! /bin/sh # Settings PIA_PASSWD_FILE=/config/pia-credentials.txt @@ -13,13 +13,6 @@ pia_client_id_file=/etc/transmission-daemon/pia_client_id transmission_settings_file=/etc/transmission-daemon/settings.json port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment -if [ -f /data/transmission-data/settings.json ]; -then - transmission_settings_file=/data/transmission-data/settings.json -else - transmission_settings_file=/etc/transmission-daemon/settings.json -fi - # # First get a port from PIA # @@ -29,7 +22,7 @@ new_client_id() { } pia_client_id="$(cat $pia_client_id_file 2>/dev/null)" -if [[ -z "$pia_client_id" ]]; then +if [ -z ${pia_client_id} ]; then echo "Generating new client id for PIA" pia_client_id=$(new_client_id) fi @@ -46,7 +39,7 @@ echo "Got new port $new_port from pia" # Check if transmission remote is set up with authentication auth_enabled=$(grep 'rpc-authentication-required\"' $transmission_settings_file | grep -oE 'true|false') -if [[ "true" = "$auth_enabled" ]] +if [ "true" = "$auth_enabled" ] then echo "transmission auth required" myauth="--auth $transmission_username:$transmission_passwd" @@ -57,7 +50,7 @@ fi # get current listening port transmission_peer_port=$(transmission-remote $myauth -si | grep Listenport | grep -oE '[0-9]+') -if [[ "$new_port" != "$transmission_peer_port" ]] +if [ "$new_port" != "$transmission_peer_port" ] then transmission-remote $myauth -p "$new_port" echo "Checking port..."