2014-11-11 21:07:13 +00:00
|
|
|
#!/bin/sh
|
2015-10-07 16:45:59 +00:00
|
|
|
set -x
|
|
|
|
vpn_provider="$(echo $OPENVPN_PROVIDER | tr '[A-Z]' '[a-z]')"
|
|
|
|
vpn_provider_configs="/etc/openvpn/$vpn_provider/"
|
|
|
|
if [ ! -d "$vpn_provider_configs" ]; then
|
2015-08-18 20:23:04 +00:00
|
|
|
echo "Could not find OpenVPN provider: $OPENVPN_PROVIDER"
|
|
|
|
echo "Please check your settings."
|
|
|
|
exit 1
|
2015-08-07 21:07:55 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-18 20:23:04 +00:00
|
|
|
echo "Using OpenVPN provider: $OPENVPN_PROVIDER"
|
|
|
|
|
2015-08-07 23:10:20 +00:00
|
|
|
if [ ! -z "$OPENVPN_CONFIG" ]
|
2015-05-09 16:59:36 +00:00
|
|
|
then
|
2015-10-07 16:45:59 +00:00
|
|
|
if [ -f $vpn_provider_configs/"${OPENVPN_CONFIG}".ovpn ]
|
2015-05-09 16:59:36 +00:00
|
|
|
then
|
2015-08-07 23:10:20 +00:00
|
|
|
echo "Starting OpenVPN using config ${OPENVPN_CONFIG}.ovpn"
|
2015-10-07 16:45:59 +00:00
|
|
|
OPENVPN_CONFIG=$vpn_provider_configs/${OPENVPN_CONFIG}.ovpn
|
2015-05-09 16:59:36 +00:00
|
|
|
else
|
2015-08-07 23:10:20 +00:00
|
|
|
echo "Supplied config ${OPENVPN_CONFIG}.ovpn could not be found."
|
2015-08-07 21:07:55 +00:00
|
|
|
echo "Using default OpenVPN gateway for provider ${vpn_provider}"
|
2015-10-07 16:45:59 +00:00
|
|
|
OPENVPN_CONFIG=$vpn_provider_configs/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."
|
2015-10-07 16:45:59 +00:00
|
|
|
OPENVPN_CONFIG=$vpn_provider_configs/default.ovpn
|
2015-05-09 16:59:36 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-07 23:22:25 +00:00
|
|
|
# add OpenVPN user/pass
|
2015-08-07 21:07:55 +00:00
|
|
|
if [ "${OPENVPN_USERNAME}" = "**None**" ] || [ "${OPENVPN_PASSWORD}" = "**None**" ] ; then
|
2015-10-07 16:45:59 +00:00
|
|
|
echo "OpenVPN credentials not set. Exiting."
|
2015-05-10 16:30:28 +00:00
|
|
|
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-08-15 14:58:21 +00:00
|
|
|
chmod 600 /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
|
2015-08-09 19:00:49 +00:00
|
|
|
dockerize -template /etc/transmission/environment-variables.tmpl:/etc/transmission/environment-variables.sh /bin/true
|
2015-05-24 18:40:25 +00:00
|
|
|
|
2015-08-07 23:10:20 +00:00
|
|
|
exec openvpn --config "$OPENVPN_CONFIG"
|