2014-11-11 21:07:13 +00:00
|
|
|
#!/bin/sh
|
2015-10-07 16:45:59 +00:00
|
|
|
set -x
|
2015-08-07 21:07:55 +00:00
|
|
|
|
2018-02-02 09:33:40 +00:00
|
|
|
# create directory to store openvpn config files
|
|
|
|
mkdir -p /config/openvpn
|
2015-08-18 20:23:04 +00:00
|
|
|
|
2018-02-02 09:33:40 +00:00
|
|
|
#Locate first file with .ovpn extension
|
|
|
|
export VPN_CONFIG=$(find /config/openvpn -maxdepth 1 -name "*.ovpn" -print -quit)
|
|
|
|
|
|
|
|
if [[ -z "${VPN_CONFIG}" ]]; then
|
|
|
|
echo "No ovpn file found. Add one to /config/openvpon abd restart this container, exiting..." | ts '%Y-%m-%d %H:%M:%.S' && exit 1
|
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
|
|
|
|
|
2018-02-02 09:33:40 +00:00
|
|
|
exec openvpn --config "$VPN_CONFIG"
|