ovpn_genconfig: Add generate config script

* Create a generate config script so that the new docker containers can
  regenerate the OpenVPN configuration without clobbering the PKI setup.
This commit is contained in:
Kyle Manna 2014-06-04 16:49:13 -07:00
parent d180cce5d0
commit e1902bc2cd
2 changed files with 37 additions and 21 deletions

36
bin/ovpn_genconfig Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
#
# Generate OpenVPN configs
#
set -ex
cn=$1
if [ -z "$cn" ]; then
echo "Common name not specified"
exit 1
fi
cat > "$OPENVPN/udp1194.conf" <<EOF
server 192.168.255.128 255.255.255.128
verb 3
#duplicate-cn
key $EASYRSA_PKI/private/$cn.key
ca $EASYRSA_PKI/ca.crt
cert $EASYRSA_PKI/issued/$cn.crt
dh $EASYRSA_PKI/dh.pem
tls-auth $EASYRSA_PKI/ta.key
key-direction 0
keepalive 10 60
persist-key
persist-tun
push "dhcp-option DNS 8.8.4.4"
push "dhcp-option DNS 8.8.8.8"
proto udp
port 1194
dev tun1194
status /tmp/openvpn-status-1194.log
EOF

View File

@ -36,24 +36,4 @@ echo "$cn" > $OPENVPN/servername
easyrsa build-server-full $cn nopass easyrsa build-server-full $cn nopass
[ -f "$OPENVPN/udp1194.conf" ] || cat > "$OPENVPN/udp1194.conf" <<EOF ovpn_genconfig "$cn"
server 192.168.255.128 255.255.255.128
verb 3
#duplicate-cn
key $EASYRSA_PKI/private/$cn.key
ca $EASYRSA_PKI/ca.crt
cert $EASYRSA_PKI/issued/$cn.crt
dh $EASYRSA_PKI/dh.pem
tls-auth $EASYRSA_PKI/ta.key
key-direction 0
keepalive 10 60
persist-key
persist-tun
push "dhcp-option DNS 8.8.4.4"
push "dhcp-option DNS 8.8.8.8"
proto udp
port 1194
dev tun1194
status /tmp/openvpn-status-1194.log
EOF