docker-qBittorrentvpn/openvpn/start.sh

29 lines
875 B
Bash
Raw Normal View History

#!/bin/sh
2015-10-07 16:45:59 +00:00
set -x
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
fi
2015-08-07 23:22:25 +00:00
# add OpenVPN user/pass
if [ "${OPENVPN_USERNAME}" = "**None**" ] || [ "${OPENVPN_PASSWORD}" = "**None**" ] ; then
2018-02-03 01:44:23 +00:00
echo "OpenVPN credentials not set. Exiting."
exit 1
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
fi
2018-02-02 09:33:40 +00:00
exec openvpn --config "$VPN_CONFIG"