-
Notifications
You must be signed in to change notification settings - Fork 9
/
softether-installer.sh
96 lines (89 loc) · 2.77 KB
/
softether-installer.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
#!/bin/bash
## Root Check
function root-check() {
if [[ "$EUID" -ne 0 ]]; then
echo "You need root access to run this script."
exit
fi
}
root-check
## Detect Operating System
function dist-check() {
if [ -e /etc/centos-release ]; then
DISTRO="CentOS"
elif [ -e /etc/redhat-release ]; then
DISTRO="Redhat"
elif [ -e /etc/debian_version ]; then
DISTRO=$(lsb_release -is)
else
echo "Your distribution is not supported (yet)."
exit
fi
}
dist-check
## Install SoftEther
function install-softether() {
if [ "$DISTRO" == "Ubuntu" ] || [ "$DISTRO" == "Debian" ] || [ "$DISTRO" == "Raspbian" ]; then
apt update -y
apt install wget curl git nano build-essential cmake libncurses-dev libreadline-dev libssl-dev zlib1g-dev -y
elif [ "$DISTRO" == "CentOS" ] || [ "$DISTRO" == "Redhat" ]; then
yum update -y
yum install epel-release -y
yum groupinstall "development tools" -y
yum install wget curl git nano cmake3 readline-devel ncurses-devel openssl-devel -y
fi
cd $HOME
rm SoftEtherVPN -rf
git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git || exit $?
cd SoftEtherVPN
git submodule update --init --recursive
if [ "$DISTRO" == "CentOS" ] || [ "$DISTRO" == "Redhat" ]; then
sed -i.bak 's/cmake/cmake3/g' configure
fi
./configure || exit $?
cd tmp
make || exit $?
make install || exit $?
}
install-softether
## Check if firewalld is exist
function check-firewalld() {
if [[ $(firewall-cmd --state) ]]; then
FIREWALLD_INSTALLED="true"
ZONE=$(firewall-cmd --get-default-zone)
else
FIREWALLD_INSTALLED="false"
fi
}
check-firewalld
## Set firewalld rules
function set-firewalld-rules() {
if [ "$FIREWALLD_INSTALLED" == "true" ]; then
ZONE=$(firewall-cmd --get-default-zone)
firewall-cmd --zone=$ZONE --add-service=openvpn --permanent
firewall-cmd --zone=$ZONE --add-service=ipsec --permanent
firewall-cmd --zone=$ZONE --add-service=https --permanent
firewall-cmd --zone=$ZONE --add-port=992/tcp --permanent
# 1194 UDP might not be opened
# If you get TLS error, this may be the cause
firewall-cmd --zone=$ZONE --add-port=1194/udp --permanent
# NAT-T
# Ref: https://blog.cles.jp/item/7295
firewall-cmd --zone=$ZONE --add-port=500/udp --permanent
firewall-cmd --zone=$ZONE --add-port=1701/udp --permanent
firewall-cmd --zone=$ZONE --add-port=4500/udp --permanent
# SoftEther
firewall-cmd --zone=$ZONE --add-port=5555/tcp --permanent
# For UDP Acceleration
firewall-cmd --zone=$ZONE --add-port=40000-44999/udp --permanent
firewall-cmd --reload
fi
}
set-firewalld-rules
systemctl daemon-reload
systemctl enable softether-vpnserver
systemctl start softether-vpnserver
systemctl status softether-vpnserver
echo ""
echo "Finished Installation! Please read this page for further information:"
echo "https://github.com/DediData/SoftEther-VPN-Installer"