-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup_server.sh
executable file
·49 lines (39 loc) · 938 Bytes
/
setup_server.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
#!/bin/bash
#
# setup_server.sh - configure openvpn server
#
OPENVPN_ETC="/etc/openvpn/"
SERVER_CERT="myserver"
FILES="dh2048.pem ${SERVER_CERT}.crt server.conf setup_server.sh \
dynamicSetup.sh ${SERVER_CERT}.key ca.crt"
# make sure this is being run with root privileges
if [ $(id -u) -ne 0 ]
then
echo "ERROR: this script must be run as root."
exit 1
fi
# make sure all files are present
for f in ${FILES}
do
if [ ! -e $f ]
then
echo "ERROR: missing $f. Exiting."
exit 1
fi
done
# make sure the target directory exists
if [ ! -d ${OPENVPN_ETC} ]
then
echo "ERROR: ${OPENVPN_ETC} does not exist."
echo " Check the openvpn installation."
exit 1
fi
# copy file files
cp ${FILES} ${OPENVPN_ETC}
# set the file ownership to root
cd ${OPENVPN_ETC}
chown root:root ${FILES}
# set file permissions
chmod 644 ${FILES}
chmod 755 dynamicSetup.sh
chmod 600 ${SERVER_CERT}.key