mirror of
https://github.com/haugene/docker-transmission-openvpn.git
synced 2025-09-05 13:51:51 +02:00
Delay --up script execution until after TCP/UDP connection establishment with peer. Also add error handling with logging when PIA port response is empty, issue #220
This commit is contained in:
parent
9671707d1d
commit
0ba2a55cbb
@ -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-delay --up /etc/transmission/start.sh --down /etc/transmission/stop.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}}')
|
||||||
|
@ -31,11 +31,16 @@ fi
|
|||||||
# Get the port
|
# Get the port
|
||||||
port_assignment_url="http://209.222.18.222:2000/?client_id=$pia_client_id"
|
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
|
||||||
|
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)
|
# Check for curl error (curl will fail on HTTP errors with -f flag)
|
||||||
ret=$?
|
if [ $pia_curl_exit_code -ne 0 ]; then
|
||||||
if [ $ret -ne 0 ]; then
|
echo "curl encountered an error looking up new port: $pia_curl_exit_code"
|
||||||
echo "curl encountered an error looking up new port: $ret"
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for errors in PIA response
|
# Check for errors in PIA response
|
||||||
@ -63,7 +68,7 @@ if [ "true" = "$auth_enabled" ]
|
|||||||
then
|
then
|
||||||
echo "transmission auth required"
|
echo "transmission auth required"
|
||||||
myauth="--auth $transmission_username:$transmission_passwd"
|
myauth="--auth $transmission_username:$transmission_passwd"
|
||||||
else
|
else
|
||||||
echo "transmission auth not required"
|
echo "transmission auth not required"
|
||||||
myauth=""
|
myauth=""
|
||||||
fi
|
fi
|
||||||
@ -75,6 +80,6 @@ if [ "$new_port" != "$transmission_peer_port" ]
|
|||||||
transmission-remote $myauth -p "$new_port"
|
transmission-remote $myauth -p "$new_port"
|
||||||
echo "Checking port..."
|
echo "Checking port..."
|
||||||
sleep 10 && transmission-remote $myauth -pt
|
sleep 10 && transmission-remote $myauth -pt
|
||||||
else
|
else
|
||||||
echo "No action needed, port hasn't changed"
|
echo "No action needed, port hasn't changed"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user