docker-qBittorrentvpn/openvpn/start.sh

27 lines
822 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
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
fi
2015-08-07 23:22:25 +00:00
# add OpenVPN user/pass
if [ "${OPENVPN_USERNAME}" = "**None**" ] || [ "${OPENVPN_PASSWORD}" = "**None**" ] ; then
2015-10-07 16:45:59 +00:00
echo "OpenVPN credentials not set. Exiting."
exit 1
else
echo "Setting OPENVPN credentials..."
mkdir -p /config
echo $OPENVPN_USERNAME > /config/openvpn-credentials.txt
echo $OPENVPN_PASSWORD >> /config/openvpn-credentials.txt
chmod 600 /config/openvpn-credentials.txt
fi
2018-02-02 09:33:40 +00:00
exec openvpn --config "$VPN_CONFIG"