mirror of
https://github.com/haugene/docker-transmission-openvpn.git
synced 2025-08-12 09:17:07 +02:00
Abstracted the transmission up and down events to seperate scripts
This commit is contained in:
parent
af699006c7
commit
0ba1bc6af7
@ -44,7 +44,7 @@ echo $TRANSMISSION_RPC_PASSWORD >> /config/transmission-credentials.txt
|
|||||||
# Persist transmission settings for use by transmission-daemon
|
# Persist transmission settings for use by transmission-daemon
|
||||||
dockerize -template /etc/transmission/environment-variables.tmpl:/etc/transmission/environment-variables.sh /bin/true
|
dockerize -template /etc/transmission/environment-variables.tmpl:/etc/transmission/environment-variables.sh /bin/true
|
||||||
|
|
||||||
TRANSMISSION_CONTROL_OPTS="--script-security 2 --up /etc/transmission/start.sh --down /etc/transmission/stop.sh"
|
TRANSMISSION_CONTROL_OPTS="--script-security 2 --up /etc/openvpn/tunnelUp.sh --down /etc/openvpn/tunnelDown.sh"
|
||||||
|
|
||||||
if [ -n "${LOCAL_NETWORK-}" ]; then
|
if [ -n "${LOCAL_NETWORK-}" ]; then
|
||||||
eval $(/sbin/ip r l m 0.0.0.0 | awk '{if($5!="tun0"){print "GW="$3"\nINT="$5; exit}}')
|
eval $(/sbin/ip r l m 0.0.0.0 | awk '{if($5!="tun0"){print "GW="$3"\nINT="$5; exit}}')
|
||||||
@ -54,15 +54,4 @@ if [ -n "${LOCAL_NETWORK-}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "${WEBPROXY_ENABLED}" = "true" ]; then
|
|
||||||
if [ -z "$WEBPROXY_PORT" ] ; then
|
|
||||||
/opt/tinyproxy/setport.sh $WEBPROXY_PORT
|
|
||||||
else
|
|
||||||
# Alway default back to port 8888
|
|
||||||
/opt/tinyproxy/setport.sh 8888
|
|
||||||
fi
|
|
||||||
/etc/init.d/tinyproxy start
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec openvpn $TRANSMISSION_CONTROL_OPTS $OPENVPN_OPTS --config "$OPENVPN_CONFIG"
|
exec openvpn $TRANSMISSION_CONTROL_OPTS $OPENVPN_OPTS --config "$OPENVPN_CONFIG"
|
||||||
|
3
openvpn/tunnelDown.sh
Executable file
3
openvpn/tunnelDown.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/etc/transmission/stop.sh
|
4
openvpn/tunnelUp.sh
Executable file
4
openvpn/tunnelUp.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/etc/transmission/start.sh
|
||||||
|
/etc/tinyproxy/start.sh
|
@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
PROXY_CONF='/etc/tinyproxy.conf'
|
|
||||||
|
|
||||||
re='^[0-9]+$'
|
|
||||||
if ! [[ $1 =~ $re ]] ; then
|
|
||||||
echo "Port: Not a number" >&2; exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Port: Specify the port which tinyproxy will listen on. Please note
|
|
||||||
# that should you choose to run on a port lower than 1024 you will need
|
|
||||||
# to start tinyproxy using root.
|
|
||||||
|
|
||||||
if [ $1 \< 1024 ];
|
|
||||||
then
|
|
||||||
echo "tinyproxy: $1 is lower than 1024. Ports below 1024 are not permitted.";
|
|
||||||
exit 1
|
|
||||||
fi;
|
|
||||||
|
|
||||||
echo "Setting tinyproxy port to $1";
|
|
||||||
sed -i -e"s,^Port .*,Port $1," $PROXY_CONF
|
|
||||||
|
|
||||||
exit 0
|
|
42
tinyproxy/start.sh
Executable file
42
tinyproxy/start.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PROXY_CONF='/etc/tinyproxy.conf'
|
||||||
|
|
||||||
|
if [ "${WEBPROXY_ENABLED}" = "true" ]; then
|
||||||
|
|
||||||
|
echo "STARTING TINYPROXY"
|
||||||
|
|
||||||
|
if [ -z "$WEBPROXY_PORT" ] ; then
|
||||||
|
set_port $WEBPROXY_PORT
|
||||||
|
else
|
||||||
|
# Always default back to port 8888
|
||||||
|
set_port 8888
|
||||||
|
fi
|
||||||
|
|
||||||
|
/etc/init.d/tinyproxy start
|
||||||
|
echo "Tinyproxy startup script complete."
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
set_port () {
|
||||||
|
|
||||||
|
re='^[0-9]+$'
|
||||||
|
if ! [[ $1 =~ $re ]] ; then
|
||||||
|
echo "Port: Not a number" >&2; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Port: Specify the port which tinyproxy will listen on. Please note
|
||||||
|
# that should you choose to run on a port lower than 1024 you will need
|
||||||
|
# to start tinyproxy using root.
|
||||||
|
|
||||||
|
if [ $1 \< 1024 ];
|
||||||
|
then
|
||||||
|
echo "tinyproxy: $1 is lower than 1024. Ports below 1024 are not permitted.";
|
||||||
|
exit 1
|
||||||
|
fi;
|
||||||
|
|
||||||
|
echo "Setting tinyproxy port to $1";
|
||||||
|
sed -i -e"s,^Port .*,Port $1," $PROXY_CONF
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user