-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvpn
executable file
·201 lines (173 loc) · 4.2 KB
/
vpn
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
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
action=$1
function start_fas_service(){
/root/res/fas-service >/dev/null 2>&1
}
function stop_fas_service(){
killall -9 fas-service
}
function start_proxy()
{
printf "%-70s" "Start Proxy"
cat /root/res/portlist.conf | while read line
do
port=`echo $line | cut -d \ -f 2`
/root/res/proxy.bin -l $port -d >/dev/null 2>&1
done
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Start Monitor"
/bin/jk.sh & >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Start FasAUTH"
/bin/FasAUTH.bin -c "/etc/openvpn/auth_config.conf" >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Start OpenVPN Proxy"
/bin/openvpn.bin -l 443 -d >/dev/null 2>&1
/bin/openvpn.bin -l 3389 -d >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
return
}
function stop_proxy()
{
printf "%-70s" "Stop proxy"
killall -9 proxy.bin >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Stop Monitor"
killall -9 jk.sh >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Stop FasAUTH"
killall -9 FasAUTH.bin >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Stop OpenVPN Proxy"
killall openvpn.bin >/dev/null 2>&1
echo -e "[ \033[32m done \033[0m ]"
return
}
function startall(){
(start_fas_service)
systemctl start mariadb.service
systemctl start httpd.service
systemctl start openvpn@server1194
systemctl start openvpn@server1195
systemctl start openvpn@server1196
systemctl start openvpn@server1197
systemctl start openvpn@server-udp
systemctl start iptables.service
systemctl start dnsmasq.service
systemctl start crond.service
(start_proxy)
return
}
function restart(){
echo -e ""
echo -e ""
echo -e ""
echo -e "\033[32m[\033[0m 请耐心等待,此过程可能需要几分钟! \033[32m]\033[0m"
echo -e ""
echo -e ""
(stop_proxy)
printf "%-70s" "Restart mariadb"
systemctl restart mariadb.service
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Restart Apache"
killall -9 httpd; #杀死 提升速度
systemctl restart httpd.service
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Restart OpenVPN"
killall -9 openvpn; #杀死 提升速度
systemctl restart openvpn@server1194
systemctl restart openvpn@server1195
systemctl restart openvpn@server1196
systemctl restart openvpn@server1197
systemctl restart openvpn@server-udp
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Restart iptables"
systemctl restart iptables.service
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Restart dnsmasq"
systemctl restart dnsmasq.service
echo -e "[ \033[32m done \033[0m ]"
printf "%-70s" "Restart crond"
systemctl restart crond.service
echo -e "[ \033[32m done \033[0m ]"
(start_proxy)
killall -9 fas_openvpn
echo -e "\033[32m[\033[0m 关闭 fas_openvpn\033[32m]\033[0m"
(fas_openvpn &)
echo -e "\033[32m[\033[0m 启动 fas_openvpn\033[32m]\033[0m"
echo -e ""
echo -e ""
echo -e "\033[32m[\033[0m 感谢您的等待,系统已经重启完毕! \033[32m]\033[0m"
return
}
function stopall(){
(stop_proxy)
(stop_fas_service)
systemctl stop mariadb.service
systemctl stop httpd.service
systemctl stop openvpn@server1194
systemctl stop openvpn@server1195
systemctl stop openvpn@server1196
systemctl stop openvpn@server1197
systemctl stop openvpn@server-udp
systemctl stop iptables.service
systemctl stop dnsmasq.service
systemctl stop crond.service
return
}
case $action in
"start")
(startall)
echo -e "已经启动"
;;
"restart")
(stop_fas_service)
(restart)
(start_fas_service)
;;
"r")
(stop_fas_service)
(restart)
(start_fas_service)
;;
"s")
(stopall)
;;
"restartvpn")
(restart)
;;
"stop")
(stopall)
;;
"start_proxy")
(start_proxy)
;;
"restart_proxy")
(stop_proxy)
(start_proxy)
;;
"stop_proxy")
(stop_proxy)
;;
"service_start")
/bin/rate.bin
(start_fas_service)
(start_proxy)
;;
"service_restart")
killall -9 rate.bin
/bin/rate.bin
(stop_fas_service)
(stop_proxy)
(start_fas_service)
(start_proxy)
;;
"service_stop")
killall -9 rate.bin
(stop_fas_service)
(stop_proxy)
;;
*)
echo '请按照如下命令执行 vpn [start|restart|stop] 例如重启为 vpn restart'
;;
esac