From 8d43c09bfb5dcce4f7557c8e11658d6ce4cad546 Mon Sep 17 00:00:00 2001 From: Doug Daniels Date: Wed, 12 Aug 2015 23:57:47 -0500 Subject: [PATCH] Closes #23 - Ensure TRANSMISSION_HOME is on a persistent volume to store torrent resume info --- Dockerfile | 1 + transmission/environment-variables.tmpl | 2 +- transmission/start.sh | 6 ++++-- transmission/updatePort.sh | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6258774..9fa4160 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,6 +94,7 @@ ENV PIA_USERNAME=**None** \ "TRANSMISSION_UTP_ENABLED=true" \ "TRANSMISSION_WATCH_DIR=/data/watch" \ "TRANSMISSION_WATCH_DIR_ENABLED=true" \ + "TRANSMISSION_HOME=/data/transmission-home" \ RESOLV_OVERRIDE=**None** # Expose port and run diff --git a/transmission/environment-variables.tmpl b/transmission/environment-variables.tmpl index 5959f7e..47c0421 100644 --- a/transmission/environment-variables.tmpl +++ b/transmission/environment-variables.tmpl @@ -1,5 +1,5 @@ #! /bin/sh - +export TRANSMISSION_HOME={{ .Env.TRANSMISSION_HOME }} 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 }} diff --git a/transmission/start.sh b/transmission/start.sh index 8c5e76f..0b5f580 100755 --- a/transmission/start.sh +++ b/transmission/start.sh @@ -8,10 +8,12 @@ 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 +# Ensure TRANSMISSION_HOME is created +mkdir -p ${TRANSMISSION_HOME} +dockerize -template /etc/transmission-daemon/settings.tmpl:${TRANSMISSION_HOME}/settings.json /bin/true echo "STARTING TRANSMISSION" -exec /usr/bin/transmission-daemon -g /etc/transmission-daemon/ & +exec /usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} & echo "STARTING PORT UPDATER" exec /etc/transmission-daemon/periodicUpdates.sh & diff --git a/transmission/updatePort.sh b/transmission/updatePort.sh index dae3703..3afe85e 100755 --- a/transmission/updatePort.sh +++ b/transmission/updatePort.sh @@ -1,5 +1,8 @@ #! /bin/sh +# Source our persisted env variables from container startup +. /etc/transmission-daemon/environment-variables.sh + # Settings PIA_PASSWD_FILE=/config/pia-credentials.txt TRANSMISSION_PASSWD_FILE=/config/transmission-credentials.txt @@ -10,7 +13,7 @@ transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE) transmission_passwd=$(tail -1 $TRANSMISSION_PASSWD_FILE) local_vpn_ip=$(ip addr show tun0 | grep inet | awk '{ print $2 }') pia_client_id_file=/etc/transmission-daemon/pia_client_id -transmission_settings_file=/etc/transmission-daemon/settings.json +transmission_settings_file=${TRANSMISSION_HOME}/settings.json port_assignment_url=https://www.privateinternetaccess.com/vpninfo/port_forward_assignment #