-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
191 lines (172 loc) · 4.21 KB
/
install.sh
File metadata and controls
191 lines (172 loc) · 4.21 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
latest="v4.22-9634-beta"
lateststable="v4.20-9608-rtm-2016.04.17"
#Release Date: 2015-10-19
initfile="vpnserver2"
echo "--------------------------------------------------------------------"
echo "SoftEther VPN Server Install script"
echo "By AhmadShamli"
echo "http://github.com/harris1391"
echo "http://harris1391.com"
echo "credit: DigitalOcean and StackOverflow"
echo "https://www.digitalocean.com/community/tutorials/how-to-setup-a-multi-protocol-vpn-server-using-softether"
echo "--------------------------------------------------------------------"
echo "--------------------------------------------------------------------"
echo
echo "Select Architecture"
echo
echo " 1. Arm EABI (32bit)"
echo " 2. Intel x86 (32bit)"
echo " 3. Intel x64/AMD64 (64bit)"
echo
echo "Please choose architecture: "
read tmp
echo
if test "$tmp" = "3"
then
arch="64bit_-_Intel_x64_or_AMD64"
arch2="x64-64bit"
echo "Selected : 1 " $arch
elif test "$tmp" = "2"
then
arch="32bit_-_Intel_x86"
arch2="x86-32bit"
echo "Selected : 2 " $arch
elif test "$tmp" = "1"
then
arch="32bit_-_ARM_EABI"
arch2="arm_eabi-32bit"
echo "Selected : 3 " $arch
else #default if non selected
arch="32bit_-_Intel_x86"
arch2="x86-32bit"
echo "Selected : 2 " $arch
fi
echo "--------------------------------------------------------------------"
echo
echo "Select OS"
echo
echo " 1. Debian/Ubuntu"
echo " 2. CentOS/Fedora"
echo
echo "Please choose OS: "
read tmp
echo
if test "$tmp" = "2"
then
os="cent"
echo "Selected : 2 CentOS/Fedora"
else
os="deb"
echo "Selected : 1 Debian/Ubuntu"
fi
echo "--------------------------------------------------------------------"
echo
echo "Select build"
echo
echo " 1. latest(might include beta/rc)"
echo " 2. latest stable"
echo
echo "Please choose build: "
read tmp
echo
if test "$tmp" = "2"
then
version="$lateststable"
echo "Latest stable selected: 2 "$lateststable
else
version="$latest"
echo "Latest build(stable/beta) selected: 1 "$latest
fi
file="softether-vpnserver-"$version"-linux-"$arch2".tar.gz"
link="http://www.softether-download.com/files/softether/"$version"-tree/Linux/SoftEther_VPN_Server/"$arch"/"$file
if [ ! -s "$file" ]||[ ! -r "$file" ];then
#remove and redownload empty or unreadable file
rm -f "$link"
wget "$link"
elif [ ! -f "file" ];then
#download if not exist
wget "$file"
fi
if [ -f "$file" ];then
tar xzf "$file"
dir=$(pwd)
echo "current dir " $dir
cd vpnserver
dir=$(pwd)
echo "changed to dir " $dir
else
echo "Archive not found. Please rerun this script or check permission."
break
fi
if [ "$os" -eq "cent" ];then
yum upgrade
yum groupinstall "Development Tools" gcc
else
apt-get update && apt-get upgrade
apt-get install build-essential -y
fi
make
cd ..
mv vpnserver /usr/local
dir=$(pwd)
echo "current dir " $dir
cd /usr/local/vpnserver/
dir=$(pwd)
echo "changed to dir " $dir
chmod 600 *
chmod 700 vpnserver
chmod 700 vpncmd
mkdir /var/lock/subsys
touch /etc/init.d/"$initfile"
#need to cat two time to pass varible($initfile) value inside
cat > /etc/init.d/"$initfile" <<EOF
#!/bin/sh
# chkconfig: 2345 99 01
# description: SoftEther VPN Server
DAEMON=/usr/local/vpnserver/$initfile
LOCK=/var/lock/subsys/$initfile
EOF
cat >> /etc/init.d/"$initfile" <<'EOF'
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
EOF
chmod 755 /etc/init.d/"$initfile"
if [ "$os" -eq "cent" ];then
chkconfig --add "$initfile"
/etc/init.d/"$initfile" start
else
update-rc.d "$initfile" defaults
/etc/init.d/"$initfile" start
fi
echo "--------------------------------------------------------------------"
echo "--------------------------------------------------------------------"
echo "Installation done. Hurray."
echo "Now you may want to change VPN server password."
echo "Run in terminal:"
echo "./vpncmd"
echo "Press 1 to select \"Management of VPN Server or VPN Bridge\","
echo "then press Enter without typing anything to connect to the "
echo "localhost server, and again press Enter without inputting "
echo "anything to connect to server by server admin mode."
echo "Then use command below to change admin password:"
echo "ServerPasswordSet"
echo "Done...."