Merge branch 'dev' into master

This commit is contained in:
jandrews377
2018-01-02 08:46:33 +13:00
committed by GitHub
10540 changed files with 573798 additions and 365039 deletions

View File

@@ -65,8 +65,6 @@ export TRANSMISSION_SPEED_LIMIT_UP_ENABLED={{ .Env.TRANSMISSION_SPEED_LIMIT_UP_E
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 }}
@@ -76,6 +74,7 @@ export TRANSMISSION_WATCH_DIR_ENABLED={{ .Env.TRANSMISSION_WATCH_DIR_ENABLED }}
export OPENVPN_PROVIDER={{ .Env.OPENVPN_PROVIDER }}
export ENABLE_UFW={{ .Env.ENABLE_UFW }}
export TRANSMISSION_WEB_UI={{ .Env.TRANSMISSION_WEB_UI }}
export PUID={{ .Env.PUID }}
export PGID={{ .Env.PGID }}
@@ -83,3 +82,6 @@ export PGID={{ .Env.PGID }}
# Need to pass through our tinyproxy settings
export WEBPROXY_ENABLED={{ .Env.WEBPROXY_ENABLED }}
export WEBPROXY_PORT={{ .Env.WEBPROXY_PORT }}
# Support custom web frontend
{{ if .Env.TRANSMISSION_WEB_HOME }} export TRANSMISSION_WEB_HOME={{ .Env.TRANSMISSION_WEB_HOME }} {{end}}

View File

@@ -64,8 +64,6 @@
"start-added-torrents": {{ .Env.TRANSMISSION_START_ADDED_TORRENTS }},
"trash-original-torrent-files": {{ .Env.TRANSMISSION_TRASH_ORIGINAL_TORRENT_FILES }},
"umask": {{ .Env.TRANSMISSION_UMASK }},
"upload-limit": {{ .Env.TRANSMISSION_UPLOAD_LIMIT }},
"upload-limit-enabled": {{ .Env.TRANSMISSION_UPLOAD_LIMIT_ENABLED }},
"upload-slots-per-torrent": {{ .Env.TRANSMISSION_UPLOAD_SLOTS_PER_TORRENT }},
"utp-enabled": {{ .Env.TRANSMISSION_UTP_ENABLED }},
"watch-dir": "{{ .Env.TRANSMISSION_WATCH_DIR }}",

View File

@@ -5,13 +5,30 @@
# This script will be called with tun/tap device name as parameter 1, and local IP as parameter 4
# See https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html (--up cmd)
echo "Up script executed with $*"
if [ "$4" = "" ]; then
echo "ERROR, unable to obtain tunnel address"
echo "killing $PPID"
kill -9 $PPID
exit 1
fi
echo "Updating TRANSMISSION_BIND_ADDRESS_IPV4 to the ip of $1 : $4"
export TRANSMISSION_BIND_ADDRESS_IPV4=$4
if [ "combustion" = "$TRANSMISSION_WEB_UI" ]; then
echo "Using Combustion UI, overriding TRANSMISSION_WEB_HOME"
export TRANSMISSION_WEB_HOME=/opt/transmission-ui/combustion-release
fi
if [ "kettu" = "$TRANSMISSION_WEB_UI" ]; then
echo "Using Kettu UI, overriding TRANSMISSION_WEB_HOME"
export TRANSMISSION_WEB_HOME=/opt/transmission-ui/kettu
fi
echo "Generating transmission settings.json from env variables"
# Ensure TRANSMISSION_HOME is created
mkdir -p ${TRANSMISSION_HOME}
dockerize -template /etc/transmission/settings.tmpl:${TRANSMISSION_HOME}/settings.json /bin/true
dockerize -template /etc/transmission/settings.tmpl:${TRANSMISSION_HOME}/settings.json
if [ ! -e "/dev/random" ]; then
# Avoid "Fatal: no entropy gathering module detected" error
@@ -22,7 +39,7 @@ fi
. /etc/transmission/userSetup.sh
echo "STARTING TRANSMISSION"
exec sudo -u ${RUN_AS} /usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log &
exec sudo -E -u ${RUN_AS} /usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log &
if [ "$OPENVPN_PROVIDER" = "PIA" ]
then

View File

@@ -4,11 +4,8 @@
. /etc/transmission/environment-variables.sh
# Settings
PIA_PASSWD_FILE=/config/openvpn-credentials.txt
TRANSMISSION_PASSWD_FILE=/config/transmission-credentials.txt
pia_username=$(head -1 $PIA_PASSWD_FILE)
pia_passwd=$(tail -1 $PIA_PASSWD_FILE)
transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE)
transmission_passwd=$(tail -1 $TRANSMISSION_PASSWD_FILE)
pia_client_id_file=/etc/transmission/pia_client_id
@@ -19,21 +16,21 @@ transmission_settings_file=${TRANSMISSION_HOME}/settings.json
#
new_client_id() {
head -n 100 /dev/urandom | md5sum | tr -d " -" | tee $pia_client_id_file
head -n 100 /dev/urandom | sha256sum | tr -d " -" | tee $pia_client_id_file
}
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
# Get the port
port_assignment_url="http://209.222.18.222:2000/?client_id=$pia_client_id"
pia_response=$(curl -s -f $port_assignment_url)
pia_response=$(curl -s -f "$port_assignment_url")
pia_curl_exit_code=$?
if [ -z $pia_response ]; then
if [ -z "$pia_response" ]; then
echo "Port forwarding is already activated on this connection, has expired, or you are not connected to a PIA region that supports port forwarding"
fi
@@ -44,14 +41,14 @@ if [ $pia_curl_exit_code -ne 0 ]; then
fi
# Check for errors in PIA response
error=$(echo $pia_response | grep -oE "\"error\".*\"")
error=$(echo "$pia_response" | grep -oE "\"error\".*\"")
if [ ! -z "$error" ]; then
echo "PIA returned an error: $error"
exit
fi
# Get new port, check if empty
new_port=$(echo $pia_response | grep -oE "[0-9]+")
new_port=$(echo "$pia_response" | grep -oE "[0-9]+")
if [ -z "$new_port" ]; then
echo "Could not find new port from PIA"
exit
@@ -63,7 +60,8 @@ 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')
auth_enabled=$(grep 'rpc-authentication-required\"' "$transmission_settings_file" \
| grep -oE 'true|false')
if [ "true" = "$auth_enabled" ]
then
echo "transmission auth required"
@@ -79,11 +77,11 @@ if [ "$new_port" != "$transmission_peer_port" ]; then
if [ "true" = "$ENABLE_UFW" ]; then
echo "Update UFW rules before changing port in Transmission"
echo "denying access to $TRANSMISSION_PEER_PORT"
ufw deny $TRANSMISSION_PEER_PORT
echo "denying access to $transmission_peer_port"
ufw deny "$transmission_peer_port"
echo "allowing $new_port through the firewall"
ufw allow $new_port
ufw allow "$new_port"
fi
transmission-remote $myauth -p "$new_port"