2014-11-11 21:07:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-08-07 21:07:55 +00:00
|
|
|
if [ "$OPENVPN_PROVIDER" = "BTGUARD" ]
|
|
|
|
then
|
|
|
|
echo "VPN PROVIDER: BTGUARD"
|
|
|
|
vpn_provider="btguard"
|
|
|
|
else
|
|
|
|
echo "VPN PROVIDER: PIA"
|
|
|
|
vpn_provider="pia"
|
|
|
|
fi
|
|
|
|
|
2015-05-09 16:59:36 +00:00
|
|
|
if [ ! -z "$OPEN_VPN_CONFIG" ]
|
|
|
|
then
|
2015-08-07 21:07:55 +00:00
|
|
|
if [ -f /etc/openvpn/$vpn_provider/"${OPEN_VPN_CONFIG}".ovpn ]
|
2015-05-09 16:59:36 +00:00
|
|
|
then
|
|
|
|
echo "Starting OpenVPN using config ${OPEN_VPN_CONFIG}.ovpn"
|
2015-08-07 21:07:55 +00:00
|
|
|
OPEN_VPN_CONFIG=/etc/openvpn/$vpn_provider/${OPEN_VPN_CONFIG}.ovpn
|
2015-05-09 16:59:36 +00:00
|
|
|
else
|
|
|
|
echo "Supplied config ${OPEN_VPN_CONFIG}.ovpn could not be found."
|
2015-08-07 21:07:55 +00:00
|
|
|
echo "Using default OpenVPN gateway for provider ${vpn_provider}"
|
|
|
|
OPEN_VPN_CONFIG=/etc/openvpn/$vpn_provider/default.ovpn
|
2015-05-09 16:59:36 +00:00
|
|
|
fi
|
|
|
|
else
|
2015-08-07 21:07:55 +00:00
|
|
|
echo "No VPN configuration provided. Using default."
|
|
|
|
OPEN_VPN_CONFIG=/etc/openvpn/$vpn_provider/default.ovpn
|
2015-05-09 16:59:36 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-09 19:49:07 +00:00
|
|
|
# override resolv.conf
|
|
|
|
if [ "$RESOLV_OVERRIDE" != "**None**" ];
|
|
|
|
then
|
|
|
|
echo "Overriding resolv.conf..."
|
|
|
|
printf "$RESOLV_OVERRIDE" > /etc/resolv.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
# add PIA user/pass
|
2015-08-07 21:07:55 +00:00
|
|
|
if [ "${OPENVPN_USERNAME}" = "**None**" ] || [ "${OPENVPN_PASSWORD}" = "**None**" ] ; then
|
2015-05-10 16:30:28 +00:00
|
|
|
echo "PIA credentials not set. Exiting."
|
|
|
|
exit 1
|
|
|
|
else
|
2015-08-07 21:07:55 +00:00
|
|
|
echo "Setting OPENVPN credentials..."
|
2015-05-09 19:49:07 +00:00
|
|
|
mkdir -p /config
|
2015-08-07 21:07:55 +00:00
|
|
|
echo $OPENVPN_USERNAME > /config/openvpn-credentials.txt
|
|
|
|
echo $OPENVPN_PASSWORD >> /config/openvpn-credentials.txt
|
2015-05-09 19:49:07 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-10 20:15:25 +00:00
|
|
|
# add transmission credentials from env vars
|
|
|
|
echo $TRANSMISSION_RPC_USERNAME > /config/transmission-credentials.txt
|
|
|
|
echo $TRANSMISSION_RPC_PASSWORD >> /config/transmission-credentials.txt
|
|
|
|
|
2015-05-24 18:40:25 +00:00
|
|
|
# Persist transmission settings for use by transmission-daemon
|
|
|
|
dockerize -template /etc/transmission-daemon/environment-variables.tmpl:/etc/transmission-daemon/environment-variables.sh /bin/true
|
|
|
|
|
2015-05-09 19:49:07 +00:00
|
|
|
exec openvpn --config "$OPEN_VPN_CONFIG"
|