From 6f07f0324b04e254afe78c3d1f071effaf7a3d26 Mon Sep 17 00:00:00 2001 From: Kristian Haugene Date: Sat, 9 May 2015 18:59:36 +0200 Subject: [PATCH] choose config to use by optionally setting environment variable. --- Dockerfile | 2 +- piaconfig/config.ovpn | 21 --------------------- runOpenVpn.sh | 17 ++++++++++++++++- 3 files changed, 17 insertions(+), 23 deletions(-) delete mode 100644 piaconfig/config.ovpn diff --git a/Dockerfile b/Dockerfile index 5bd42c9..3276f33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN apt-get install -y curl VOLUME /config # Add configuration and scripts -ADD piaconfig/config.ovpn /etc/openvpn/config.ovpn +ADD piaconfig/* /etc/openvpn/ ADD piaconfig/ca.crt /etc/openvpn/ca.crt ADD piaconfig/crl.pem /etc/openvpn/crl.pem ADD transmission/defaultSettings.json /etc/transmission-daemon/settings.json diff --git a/piaconfig/config.ovpn b/piaconfig/config.ovpn deleted file mode 100644 index c3f8b06..0000000 --- a/piaconfig/config.ovpn +++ /dev/null @@ -1,21 +0,0 @@ -client -dev tun -proto udp -remote nl.privateinternetaccess.com 1194 -resolv-retry infinite -nobind -persist-key -persist-tun -ca /etc/openvpn/ca.crt -tls-client -remote-cert-tls server -auth-user-pass /config/pia-credentials.txt -comp-lzo -verb 1 -reneg-sec 0 -crl-verify /etc/openvpn/crl.pem - -# OpenVPN control startup and shut down of transmission -script-security 2 -up /etc/transmission-daemon/start.sh -down /etc/transmission-daemon/stop.sh diff --git a/runOpenVpn.sh b/runOpenVpn.sh index 4dbc3f5..6240674 100755 --- a/runOpenVpn.sh +++ b/runOpenVpn.sh @@ -1,3 +1,18 @@ #!/bin/sh -exec openvpn --config /etc/openvpn/config.ovpn +if [ ! -z "$OPEN_VPN_CONFIG" ] +then + if [ -f /etc/openvpn/"${OPEN_VPN_CONFIG}".ovpn ] + then + echo "Starting OpenVPN using config ${OPEN_VPN_CONFIG}.ovpn" + exec openvpn --config /etc/openvpn/"${OPEN_VPN_CONFIG}".ovpn + else + echo "Supplied config ${OPEN_VPN_CONFIG}.ovpn could not be found." + echo "Using default OpenVPN gateway: Netherlands" + exec openvpn --config /etc/openvpn/Netherlands.ovpn + fi +else + echo "No VPN configuration provided. Using default: Netherlands" + exec openvpn --config /etc/openvpn/Netherlands.ovpn +fi +