2014-06-04 23:49:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate OpenVPN configs
|
|
|
|
#
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2014-06-30 06:04:42 +00:00
|
|
|
servername=$(cat "$OPENVPN/servername" 2> /dev/null)
|
|
|
|
cn=${1-$servername}
|
2014-06-04 23:49:13 +00:00
|
|
|
|
|
|
|
if [ -z "$cn" ]; then
|
|
|
|
echo "Common name not specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-06-30 06:09:18 +00:00
|
|
|
conf=$OPENVPN/udp1194.conf
|
|
|
|
if [ -f "$conf" ]; then
|
|
|
|
bak=$conf.$(date +%s).bak
|
|
|
|
echo "Backing up $conf -> $bak"
|
|
|
|
mv "$conf" "$bak"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat > "$conf" <<EOF
|
2014-06-30 05:45:30 +00:00
|
|
|
server 192.168.255.0 255.255.255.0
|
2014-06-04 23:49:13 +00:00
|
|
|
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"
|
2014-06-30 07:10:52 +00:00
|
|
|
|
2014-06-30 05:44:05 +00:00
|
|
|
client-config-dir $OPENVPN/ccd
|
2014-06-30 07:10:52 +00:00
|
|
|
route 192.168.254.0 255.255.255.0
|
2014-06-04 23:49:13 +00:00
|
|
|
|
|
|
|
proto udp
|
|
|
|
port 1194
|
|
|
|
dev tun1194
|
|
|
|
status /tmp/openvpn-status-1194.log
|
|
|
|
EOF
|