2014-07-01 05:43:00 +00:00
|
|
|
#!/bin/bash
|
2014-06-04 18:13:59 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Get an OpenVPN client configuration file
|
|
|
|
#
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2014-07-06 01:51:58 +00:00
|
|
|
source "$OPENVPN/ovpn_env.sh"
|
|
|
|
cn=$1
|
2014-07-01 05:43:00 +00:00
|
|
|
|
2014-07-06 01:51:58 +00:00
|
|
|
if [ ! -f "$EASYRSA_PKI/private/${cn}.key" ]; then
|
2014-07-10 16:53:24 +00:00
|
|
|
echo "Unable to find ${cn}, please try again or generate the key first"
|
|
|
|
exit 1
|
2014-06-04 18:13:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
client
|
|
|
|
nobind
|
|
|
|
dev tun
|
2014-06-04 22:38:49 +00:00
|
|
|
remote-cert-tls server
|
2014-06-04 18:13:59 +00:00
|
|
|
|
|
|
|
<key>
|
2014-07-06 01:51:58 +00:00
|
|
|
$(cat $EASYRSA_PKI/private/${cn}.key)
|
2014-06-04 18:13:59 +00:00
|
|
|
</key>
|
|
|
|
<cert>
|
2014-07-06 01:51:58 +00:00
|
|
|
$(cat $EASYRSA_PKI/issued/${cn}.crt)
|
2014-06-04 18:13:59 +00:00
|
|
|
</cert>
|
|
|
|
<ca>
|
|
|
|
$(cat $EASYRSA_PKI/ca.crt)
|
|
|
|
</ca>
|
|
|
|
<dh>
|
|
|
|
$(cat $EASYRSA_PKI/dh.pem)
|
|
|
|
</dh>
|
2014-06-04 22:34:42 +00:00
|
|
|
<tls-auth>
|
|
|
|
$(cat $EASYRSA_PKI/ta.key)
|
|
|
|
</tls-auth>
|
|
|
|
key-direction 1
|
2014-06-04 18:13:59 +00:00
|
|
|
|
2014-07-06 07:25:14 +00:00
|
|
|
remote $OVPN_CN $OVPN_PORT $OVPN_PROTO
|
2014-06-04 18:13:59 +00:00
|
|
|
EOF
|
2014-07-06 07:25:14 +00:00
|
|
|
|
|
|
|
if [ "$OVPN_DEFROUTE" != "0" ];then
|
|
|
|
echo "redirect-gateway def1"
|
|
|
|
fi
|
2015-01-17 09:07:52 +00:00
|
|
|
|
|
|
|
[ -n "$OVPN_MTU" ] && echo "tun-mtu $OVPN_MTU"
|