forked from linhbngo/cloudlab_openstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-vpn-client.sh
executable file
·57 lines (45 loc) · 942 Bytes
/
setup-vpn-client.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
##
## Setup an OpenVPN client for the management network. Just saves
## a couple SSH connections from the server driving the setup.
##
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
logtstart "vpn-client"
maybe_install_packages openvpn
cp -p $OURDIR/$HOSTNAME.crt $OURDIR/$HOSTNAME.key /etc/openvpn/
cp -p $OURDIR/ca.crt /etc/openvpn
nmfqdn=`getfqdn $NETWORKMANAGER`
cat <<EOF > /etc/openvpn/server.conf
client
dev tun
proto udp
remote $nmfqdn 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert $HOSTNAME.crt
key $HOSTNAME.key
ns-cert-type server
comp-lzo
verb 3
EOF
#
# Get the server up
#
if [ ${HAVE_SYSTEMD} -eq 1 ]; then
systemctl enable [email protected]
systemctl restart [email protected]
else
service openvpn restart
fi
logtend "vpn-client"
exit 0