-
Notifications
You must be signed in to change notification settings - Fork 355
/
uninstall.sh
312 lines (274 loc) · 9.56 KB
/
uninstall.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
shadowsocks_uninstall(){
if [ "$(command -v ss-server)" ]; then
# check Shadowsocks-libev status
${SHADOWSOCKS_LIBEV_INIT} status > /dev/null 2>&1
if [ $? -eq 0 ]; then
${SHADOWSOCKS_LIBEV_INIT} stop > /dev/null 2>&1
fi
local ss_service_name=$(basename ${SHADOWSOCKS_LIBEV_INIT})
if check_sys packageManager yum; then
chkconfig --del ${ss_service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${ss_service_name} remove
fi
elif [ "$(command -v ssservice)" ]; then
# check Shadowsocks-rust status
${SHADOWSOCKS_RUST_INIT} status > /dev/null 2>&1
if [ $? -eq 0 ]; then
${SHADOWSOCKS_RUST_INIT} stop > /dev/null 2>&1
fi
local ss_service_name=$(basename ${SHADOWSOCKS_RUST_INIT})
if check_sys packageManager yum; then
chkconfig --del ${ss_service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${ss_service_name} remove
fi
elif [ "$(command -v go-shadowsocks2)" ]; then
# check Go-shadowsocks status
${GO_SHADOWSOCKS2_INIT} status > /dev/null 2>&1
if [ $? -eq 0 ]; then
${GO_SHADOWSOCKS2_INIT} stop > /dev/null 2>&1
fi
local ss_service_name=$(basename ${GO_SHADOWSOCKS2_INIT})
if check_sys packageManager yum; then
chkconfig --del ${ss_service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${ss_service_name} remove
fi
fi
# uninstall ss-libev
rm -fr $(dirname ${SHADOWSOCKS_CONFIG})
rm -f /usr/local/bin/ss-local
rm -f /usr/local/bin/ss-tunnel
rm -f /usr/local/bin/ss-server
rm -f /usr/local/bin/ss-manager
rm -f /usr/local/bin/ss-redir
rm -f /usr/local/bin/ss-nat
rm -f /usr/local/lib/libshadowsocks-libev.a
rm -f /usr/local/lib/libshadowsocks-libev.la
rm -f /usr/local/include/shadowsocks.h
rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc
rm -f /usr/local/share/man/man1/ss-local.1
rm -f /usr/local/share/man/man1/ss-tunnel.1
rm -f /usr/local/share/man/man1/ss-server.1
rm -f /usr/local/share/man/man1/ss-manager.1
rm -f /usr/local/share/man/man1/ss-redir.1
rm -f /usr/local/share/man/man1/ss-nat.1
rm -f /usr/local/share/man/man8/shadowsocks-libev.8
rm -fr /usr/local/share/doc/shadowsocks-libev
rm -f ${SHADOWSOCKS_LIBEV_INIT}
# uninstall ss-rust
rm -f /usr/local/bin/ssserver
rm -f /usr/local/bin/sslocal
rm -f /usr/local/bin/ssurl
rm -f /usr/local/bin/ssmanager
rm -f /usr/local/bin/ssservice
rm -f ${SHADOWSOCKS_RUST_INIT}
# uninstall go-ss2
rm -rf /usr/local/bin/go-shadowsocks2
rm -rf ${GO_SHADOWSOCKS2_INIT}
}
v2ray_plugin_uninstall(){
# kill v2ray-plugin 、obfs-server、gq-server ck-server
ps -ef |grep -v grep | grep v2ray-plugin |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall v2ray-plugin
rm -f /var/run/v2ray-plugin.pid
rm -f /usr/local/bin/v2ray-plugin
}
kcptun_uninstall(){
# check kcptun status
if [ -e ${KCPTUN_INIT} ]; then
${KCPTUN_INIT} status > /dev/null 2>&1
if [ $? -eq 0 ]; then
${KCPTUN_INIT} stop > /dev/null 2>&1
fi
local kcp_service_name=$(basename ${KCPTUN_INIT})
if check_sys packageManager yum; then
chkconfig --del ${kcp_service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${kcp_service_name} remove
fi
fi
# uninstall kcptun
rm -fr ${KCPTUN_INSTALL_PATH} > /dev/null 2>&1
rm -fr $(dirname ${KCPTUN_CONFIG}) > /dev/null 2>&1
rm -f ${KCPTUN_INIT} > /dev/null 2>&1
}
simple_obfs_uninstall(){
ps -ef |grep -v grep | grep obfs-server |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall simple-obfs
rm -f /var/run/simple-obfs.pid
rm -f /usr/local/bin/obfs-local
rm -f /usr/local/bin/obfs-server
}
goquiet_uninstall(){
ps -ef |grep -v grep | grep gq-server |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall goquiet
rm -f /var/run/goquiet.pid
rm -f /usr/local/bin/gq-server
}
cloak_uninstall(){
# check cloak status
if [ -e ${CLOAK_INIT} ]; then
${CLOAK_INIT} status > /dev/null 2>&1
if [ $? -eq 0 ]; then
${CLOAK_INIT} stop > /dev/null 2>&1
fi
local ck_service_name=$(basename ${CLOAK_INIT})
if check_sys packageManager yum; then
chkconfig --del ${ck_service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${ck_service_name} remove
fi
fi
ps -ef |grep -v grep | grep ck-server |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall cloak
rm -f /usr/local/bin/ck-server
rm -f /usr/local/bin/ck-client
rm -f ${CLOAK_INIT}
rm -fr $(dirname ${CK_CLIENT_CONFIG}) > /dev/null 2>&1
}
mtt_uninstall(){
ps -ef |grep -v grep | grep mtt-server |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall mos-tls-tunnel
rm -f /var/run/mos-tls-tunnel.pid
rm -f /usr/local/bin/mtt-server
}
rabbit_tcp_uninstall(){
if [ -e ${RABBIT_INIT} ]; then
${RABBIT_INIT} status > /dev/null 2>&1
if [ $? -eq 0 ]; then
${RABBIT_INIT} stop > /dev/null 2>&1
fi
local rabbit_tcp_service_name=$(basename ${RABBIT_INIT})
if check_sys packageManager yum; then
chkconfig --del ${rabbit_tcp_service_name}
elif check_sys packageManager apt; then
update-rc.d -f ${rabbit_tcp_service_name} remove
fi
fi
ps -ef |grep -v grep | grep rabbit-tcp |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall rabbit-tcp
rm -f ${RABBIT_BIN_PATH}
rm -f ${RABBIT_INIT}
rm -fr $(dirname ${RABBIT_CONFIG}) > /dev/null 2>&1
}
simple_tls_uninstall(){
ps -ef |grep -v grep | grep simple-tls |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall mos-tls-tunnel
rm -f /var/run/simple-tls.pid
rm -f /usr/local/bin/simple-tls
rm -rf /etc/simple-tls
}
gost_plugin_uninstall(){
ps -ef |grep -v grep | grep gost-plugin |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall gost-plugin
rm -f /var/run/gost-plugin.pid
rm -f /usr/local/bin/gost-plugin
}
xray_plugin_uninstall(){
ps -ef |grep -v grep | grep xray-plugin |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall xray-plugin
rm -f /var/run/xray-plugin.pid
rm -f /usr/local/bin/xray-plugin
}
qtun_uninstall(){
ps -ef |grep -v grep | grep qtun-server |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall qtun
rm -f /var/run/qtun.pid
rm -f /usr/local/bin/qtun-server
}
gun_uninstall(){
ps -ef |grep -v grep | grep gun-server |awk '{print $2}' | xargs kill -9 > /dev/null 2>&1
# uninstall gun
rm -f /var/run/gun.pid
rm -f /usr/local/bin/gun-server
}
caddy_uninstall(){
if [[ -e ${CADDY_BIN_PATH} ]] && [[ -e ${WEB_INSTALL_MARK} ]]; then
PID=`ps -ef |grep "caddy" |grep -v "grep" |grep -v "init.d" |grep -v "service" |grep -v "caddy_install" |awk '{print $2}'`
[[ ! -z ${PID} ]] && kill -9 ${PID}
if check_sys packageManager yum; then
chkconfig --del caddy
elif check_sys packageManager apt; then
update-rc.d -f caddy remove
fi
rm -rf $(dirname ${CADDY_BIN_PATH})
rm -rf /etc/init.d/caddy
rm -rf /usr/bin/caddy
rm -rf ${WEB_INSTALL_MARK}
fi
}
nginx_uninstall(){
if [[ -e ${NGINX_BIN_PATH} ]] && [[ -e ${WEB_INSTALL_MARK} ]]; then
if check_sys packageManager yum; then
sudo yum remove -y nginx > /dev/null 2>&1
rm -rf $(dirname ${NGINX_CONFIG})
elif check_sys packageManager apt; then
sudo apt remove -y nginx --purge > /dev/null 2>&1
rm -rf $(dirname ${NGINX_CONFIG})
fi
rm -rf ${WEB_INSTALL_MARK}
fi
}
# acme_uninstall(){
# uninstall acme.sh
# /root/.acme.sh/acme.sh --uninstall > /dev/null 2>&1 && rm -rf ~/.acme.sh
# }
ipcalc_uninstall(){
# uninstall ipcalc-0.41
rm -rf /usr/local/bin/ipcalc-0.41
}
log_file_remove(){
rm -f /var/log/shadowsocks-libev.log
rm -f /var/log/shadowsocks-rust.log
rm -f /var/log/go-shadowsocks2.log
rm -f /var/log/kcptun.log
rm -f /var/log/cloak.log
rm -f /var/log/rabbit-tcp.log
rm -f /var/log/caddy-error.log
rm -f /var/log/caddy-access.log
rm -f /var/log/nginx-error.log
rm -f /var/log/nginx-access.log
}
remove_cron_job(){
if [ -z "$(crontab -l | grep 'ss-plugins.sh renew')" ]; then
return
fi
crontab -l | sed '/ss-plugins.sh renew/d' | crontab -
add_cron_job_for_acme
}
remove_added_port(){
improt_package "utils" "firewalls.sh"
get_env_variable "PORXY_INBOUND_PORT"
[ -z "${PORXY_INBOUND_PORT}" ] && return
get_env_variable "FIREWALL_MANAGE_TOOL"
[ -z "${FIREWALL_MANAGE_TOOL}" ] && return
remove_firewall_rule "${PORXY_INBOUND_PORT}" "tcp"
remove_firewall_rule "${PORXY_INBOUND_PORT}" "udp"
}
remove_env_folder(){
rm -rf ${SS_PLUGINS_SCRIPT_ENV_DIR}
}
uninstall_services(){
shadowsocks_uninstall
v2ray_plugin_uninstall
kcptun_uninstall
simple_obfs_uninstall
goquiet_uninstall
cloak_uninstall
mtt_uninstall
rabbit_tcp_uninstall
simple_tls_uninstall
gost_plugin_uninstall
xray_plugin_uninstall
qtun_uninstall
gun_uninstall
caddy_uninstall
nginx_uninstall
ipcalc_uninstall
log_file_remove
remove_cron_job
remove_added_port
remove_env_folder
}