forked from eduvpn/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_node.sh
executable file
·123 lines (88 loc) · 3.91 KB
/
deploy_node.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
#
# Deploy a VPN node
#
###############################################################################
# VARIABLES
###############################################################################
# **NOTE**: make sure WEB_FQDN is a valid DNS names with appropriate A
# (and AAAA) record!
# VARIABLES
# same as in `deploy_controller.sh`
WEB_FQDN=vpn.example
# The interface that connects to "the Internet" (for sysctl)
EXTERNAL_IF=eth0
# the API secret that was in the output of the `deploy_controller.sh` script
API_SECRET=12345
###############################################################################
# SYSTEM
###############################################################################
# SELinux enabled?
/usr/sbin/selinuxenabled
if [ "$?" -ne 0 ]
then
echo "Please enable SELinux before running this script!"
exit 1
fi
PACKAGE_MANAGER=/usr/bin/yum
###############################################################################
# SOFTWARE
###############################################################################
# remove firewalld if it is installed, too complicated for our routing
${PACKAGE_MANAGER} -y remove firewalld
# enable EPEL
${PACKAGE_MANAGER} -y install epel-release
curl -L -o /etc/yum.repos.d/fkooman-eduvpn-testing-epel-7.repo \
https://copr.fedorainfracloud.org/coprs/fkooman/eduvpn-testing/repo/epel-7/fkooman-eduvpn-testing-epel-7.repo
# install software (dependencies)
${PACKAGE_MANAGER} -y install php-opcache iptables iptables-services \
open-vm-tools php-cli policycoreutils-python
# install software (VPN packages)
${PACKAGE_MANAGER} -y install vpn-server-node
###############################################################################
# SELINUX
###############################################################################
# allow OpenVPN to bind to the management ports
semanage port -a -t openvpn_port_t -p tcp 11940-11955
###############################################################################
# PHP
###############################################################################
# set timezone to UTC
cp resources/70-timezone.ini /etc/php.d/70-timezone.ini
###############################################################################
# VPN-SERVER-NODE
###############################################################################
sed -i "s|http://localhost/vpn-server-api/api.php|https://${WEB_FQDN}/vpn-server-api/api.php|" /etc/vpn-server-node/default/config.php
# the API secret
sed -i "s|XXX-vpn-server-node/vpn-server-api-XXX|${API_SECRET}|" /etc/vpn-server-node/default/config.php
###############################################################################
# NETWORK
###############################################################################
cat << EOF > /etc/sysctl.d/70-vpn.conf
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
# allow RA for IPv6 on external interface, NOT for static IPv6!
net.ipv6.conf.${EXTERNAL_IF}.accept_ra = 2
EOF
sysctl --system
###############################################################################
# DAEMONS
###############################################################################
systemctl enable --now vmtoolsd
###############################################################################
# OPENVPN SERVER CONFIG
###############################################################################
# NOTE: the openvpn-server systemd unit file only allows 10 OpenVPN processes
# by default!
# generate the server configuration files
vpn-server-node-server-config --profile internet --generate
# enable and start OpenVPN
systemctl enable --now openvpn-server@default-internet-{0,1}
###############################################################################
# FIREWALL
###############################################################################
# generate and install the firewall
vpn-server-node-generate-firewall --install
systemctl enable --now iptables
systemctl enable --now ip6tables
# ALL DONE!