Update start.sh

This commit is contained in:
MarkusMcNugen 2018-02-02 04:33:40 -05:00 committed by GitHub
parent 92b84e7d9e
commit 2f1617200a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,29 +1,14 @@
#!/bin/sh #!/bin/sh
set -x 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
echo "Could not find OpenVPN provider: $OPENVPN_PROVIDER"
echo "Please check your settings."
exit 1
fi
echo "Using OpenVPN provider: $OPENVPN_PROVIDER" # create directory to store openvpn config files
mkdir -p /config/openvpn
if [ ! -z "$OPENVPN_CONFIG" ] #Locate first file with .ovpn extension
then export VPN_CONFIG=$(find /config/openvpn -maxdepth 1 -name "*.ovpn" -print -quit)
if [ -f $vpn_provider_configs/"${OPENVPN_CONFIG}".ovpn ]
then if [[ -z "${VPN_CONFIG}" ]]; then
echo "Starting OpenVPN using config ${OPENVPN_CONFIG}.ovpn" echo "No ovpn file found. Add one to /config/openvpon abd restart this container, exiting..." | ts '%Y-%m-%d %H:%M:%.S' && exit 1
OPENVPN_CONFIG=$vpn_provider_configs/${OPENVPN_CONFIG}.ovpn
else
echo "Supplied config ${OPENVPN_CONFIG}.ovpn could not be found."
echo "Using default OpenVPN gateway for provider ${vpn_provider}"
OPENVPN_CONFIG=$vpn_provider_configs/default.ovpn
fi
else
echo "No VPN configuration provided. Using default."
OPENVPN_CONFIG=$vpn_provider_configs/default.ovpn
fi fi
# add OpenVPN user/pass # add OpenVPN user/pass
@ -38,11 +23,4 @@ else
chmod 600 /config/openvpn-credentials.txt chmod 600 /config/openvpn-credentials.txt
fi fi
# add transmission credentials from env vars exec openvpn --config "$VPN_CONFIG"
echo $TRANSMISSION_RPC_USERNAME > /config/transmission-credentials.txt
echo $TRANSMISSION_RPC_PASSWORD >> /config/transmission-credentials.txt
# Persist transmission settings for use by transmission-daemon
dockerize -template /etc/transmission/environment-variables.tmpl:/etc/transmission/environment-variables.sh /bin/true
exec openvpn --config "$OPENVPN_CONFIG"