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
|
2018-02-02 21:53:06 +00:00
|
|
|
if [ ! -d "/config/openvpn" ]; then
|
2018-02-03 01:44:23 +00:00
|
|
|
mkdir -p /config/openvpn
|
2018-02-02 21:53:06 +00:00
|
|
|
fi
|
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
|
2018-02-03 01:44:23 +00:00
|
|
|
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
|
2018-02-03 01:44:23 +00:00
|
|
|
echo "OpenVPN credentials not set. Exiting."
|
|
|
|
exit 1
|
2015-05-10 16:30:28 +00:00
|
|
|
else
|
2018-02-03 01:44:23 +00:00
|
|
|
echo "Setting OPENVPN credentials..."
|
|
|
|
echo $OPENVPN_USERNAME > /config/openvpn/credentials.conf
|
|
|
|
echo $OPENVPN_PASSWORD >> /config/openvpn/credentials.conf
|
|
|
|
chown -R "${PUID}":"${PGID}" /config/openvpn
|
|
|
|
chmod -R 775 /config/openvpn
|
2015-05-09 19:49:07 +00:00
|
|
|
fi
|
|
|
|
|
2018-02-02 09:33:40 +00:00
|
|
|
exec openvpn --config "$VPN_CONFIG"
|