This commit is contained in:
nicknlsn
2019-10-13 17:58:02 -06:00
11754 changed files with 59790 additions and 844529 deletions

View File

@@ -1,4 +1,4 @@
#! /bin/sh
#! /bin/bash
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 }}

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Source our persisted env variables from container startup
. /etc/transmission/environment-variables.sh
@@ -6,7 +6,7 @@
# 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
if [[ "$4" = "" ]]; then
echo "ERROR, unable to obtain tunnel address"
echo "killing $PPID"
kill -9 $PPID
@@ -14,7 +14,7 @@ if [ "$4" = "" ]; then
fi
# If transmission-pre-start.sh exists, run it
if [ -x /scripts/transmission-pre-start.sh ]
if [[ -x /scripts/transmission-pre-start.sh ]]
then
echo "Executing /scripts/transmission-pre-start.sh"
/scripts/transmission-pre-start.sh "$@"
@@ -24,17 +24,17 @@ 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
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
if [[ "kettu" = "$TRANSMISSION_WEB_UI" ]]; then
echo "Using Kettu UI, overriding TRANSMISSION_WEB_HOME"
export TRANSMISSION_WEB_HOME=/opt/transmission-ui/kettu
fi
if [ "transmission-web-control" = "$TRANSMISSION_WEB_UI" ]; then
if [[ "transmission-web-control" = "$TRANSMISSION_WEB_UI" ]]; then
echo "Using Transmission Web Control UI, overriding TRANSMISSION_WEB_HOME"
export TRANSMISSION_WEB_HOME=/opt/transmission-ui/transmission-web-control
fi
@@ -47,7 +47,7 @@ dockerize -template /etc/transmission/settings.tmpl:${TRANSMISSION_HOME}/setting
echo "sed'ing True to true"
sed -i 's/True/true/g' ${TRANSMISSION_HOME}/settings.json
if [ ! -e "/dev/random" ]; then
if [[ ! -e "/dev/random" ]]; then
# Avoid "Fatal: no entropy gathering module detected" error
echo "INFO: /dev/random not found - symlink to /dev/urandom"
ln -s /dev/urandom /dev/random
@@ -55,7 +55,7 @@ fi
. /etc/transmission/userSetup.sh
if [ "true" = "$DROP_DEFAULT_ROUTE" ]; then
if [[ "true" = "$DROP_DEFAULT_ROUTE" ]]; then
echo "DROPPING DEFAULT ROUTE"
ip r del default || exit 1
fi
@@ -63,11 +63,11 @@ fi
echo "STARTING TRANSMISSION"
exec su --preserve-environment ${RUN_AS} -s /bin/bash -c "/usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log" &
if [ "$OPENVPN_PROVIDER" = "PIA" ]
if [[ "${OPENVPN_PROVIDER^^}" = "PIA" ]]
then
echo "CONFIGURING PORT FORWARDING"
exec /etc/transmission/updatePort.sh &
elif [ "$OPENVPN_PROVIDER" = "PERFECTPRIVACY" ]
elif [[ "${OPENVPN_PROVIDER^^}" = "PERFECTPRIVACY" ]]
then
echo "CONFIGURING PORT FORWARDING"
exec /etc/transmission/updatePPPort.sh ${TRANSMISSION_BIND_ADDRESS_IPV4} &
@@ -76,7 +76,7 @@ else
fi
# If transmission-post-start.sh exists, run it
if [ -x /scripts/transmission-post-start.sh ]
if [[ -x /scripts/transmission-post-start.sh ]]
then
echo "Executing /scripts/transmission-post-start.sh"
/scripts/transmission-post-start.sh "$@"

View File

@@ -1,7 +1,7 @@
#! /bin/sh
#! /bin/bash
# If transmission-pre-stop.sh exists, run it
if [ -x /scripts/transmission-pre-stop.sh ]
if [[ -x /scripts/transmission-pre-stop.sh ]]
then
echo "Executing /scripts/transmission-pre-stop.sh"
/scripts/transmission-pre-stop.sh "$@"
@@ -11,7 +11,7 @@ fi
kill $(pidof transmission-daemon)
# If transmission-post-stop.sh exists, run it
if [ -x /scripts/transmission-post-stop.sh ]
if [[ -x /scripts/transmission-post-stop.sh ]]
then
echo "Executing /scripts/transmission-post-stop.sh"
/scripts/transmission-post-stop.sh "$@"

View File

@@ -1,4 +1,4 @@
#! /bin/sh
#! /bin/bash
echo "Wait for tunnel to be fully initialized and PIA is ready to give us a port"
sleep 15
@@ -9,8 +9,8 @@ sleep 15
# Settings
TRANSMISSION_PASSWD_FILE=/config/transmission-credentials.txt
transmission_username=$(head -1 $TRANSMISSION_PASSWD_FILE)
transmission_passwd=$(tail -1 $TRANSMISSION_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
transmission_settings_file=${TRANSMISSION_HOME}/settings.json
@@ -19,11 +19,11 @@ transmission_settings_file=${TRANSMISSION_HOME}/settings.json
#
new_client_id() {
head -n 100 /dev/urandom | sha256sum | 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
pia_client_id="$(cat ${pia_client_id_file} 2>/dev/null)"
if [[ -z "${pia_client_id}" ]]; then
echo "Generating new client id for PIA"
pia_client_id=$(new_client_id)
fi
@@ -33,26 +33,26 @@ port_assignment_url="http://209.222.18.222:2000/?client_id=$pia_client_id"
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
# Check for curl error (curl will fail on HTTP errors with -f flag)
if [ $pia_curl_exit_code -ne 0 ]; then
if [[ ${pia_curl_exit_code} -ne 0 ]]; then
echo "curl encountered an error looking up new port: $pia_curl_exit_code"
exit
fi
# Check for errors in PIA response
error=$(echo "$pia_response" | grep -oE "\"error\".*\"")
if [ ! -z "$error" ]; then
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]+")
if [ -z "$new_port" ]; then
if [[ -z "$new_port" ]]; then
echo "Could not find new port from PIA"
exit
fi
@@ -65,7 +65,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"
@@ -83,8 +83,8 @@ echo "$output"
# get current listening port
transmission_peer_port=$(transmission-remote $myauth -si | grep Listenport | grep -oE '[0-9]+')
if [ "$new_port" != "$transmission_peer_port" ]; then
if [ "true" = "$ENABLE_UFW" ]; then
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"
@@ -98,7 +98,7 @@ if [ "$new_port" != "$transmission_peer_port" ]; then
echo "Checking port..."
sleep 10
transmission-remote $myauth -pt
transmission-remote ${myauth} -pt
else
echo "No action needed, port hasn't changed"
fi