-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt-uninstall.sh
132 lines (119 loc) · 3.57 KB
/
bt-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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
Remove_Bt(){
if [ ! -f "/etc/init.d/bt" ] || [ ! -d "/www/server/panel" ]; then
echo -e "此服务器没有安装宝塔!"
echo -e "This server does not install bt-panel"
exit;
fi
if [ -f "/etc/init.d/bt_syssafe" ]; then
echo -e "此服务器装有宝塔系统加固可能导致无法正常卸载,请在面板卸载后再执行卸载命令!"
exit;
fi
if [ -f "/etc/init.d/bt_tamper_proof" ]; then
echo -e "此服务器装有宝塔网站防篡改可能导致无法正常卸载,请在面板卸载后再执行卸载命令!"
exit;
fi
/etc/init.d/bt stop
if [ -f "/usr/sbin/chkconfig" ];then
chkconfig --del bt
elif [ -f "/usr/sbin/update-rc.d" ];then
update-rc.d -f bt remove
fi
rm -rf /www/server/panel
rm -f /etc/init.d/bt
echo -e "宝塔面板已卸载成功"
echo -e "bt-panel uninstall success"
}
Remove_Rpm(){
echo -e "查询已安装rpm包.."
echo -e "Find installed packages"
for lib in bt-nginx bt-httpd bt-mysql bt-curl bt-AliSQL AliSQL-master bt-mariadb bt-php-5.2 bt-php-5.3 bt-php-5.4 bt-php-5.5 bt-php-5.6 bt-php-7.0 bt-php-7.1
do
rpm -qa |grep ${lib} > ${lib}.pl
libRpm=`cat ${lib}.pl`
if [ "${libRpm}" != "" ]; then
rpm -e ${libRpm} --nodeps > /dev/null 2>&1
echo -e ${lib} "\033[32mclean\033[0m"
fi
rm -f ${lib}.pl
done
yum remove bt-openssl* -y
yum remove bt-php* -y
echo -e "清理完毕"
echo -e "Clean over"
}
Remove_Service(){
servicePath="/www/server"
for service in nginx httpd mysqld pure-ftpd tomcat redis memcached mongodb pgsql tomcat tomcat7 tomcat8 tomcat9 php-fpm-52 php-fpm-53 php-fpm-54 php-fpm-55 php-fpm-56 php-fpm-70 php-fpm-71 php-fpm-72 php-fpm-73
do
if [ -f "/etc/init.d/${service}" ]; then
/etc/init.d/${service} stop
if [ -f "/usr/sbin/chkconfig" ];then
chkconfig --del ${service}
elif [ -f "/usr/sbin/update-rc.d" ];then
update-rc.d -f ${service} remove
fi
if [ "${service}" = "mysqld" ]; then
rm -rf ${servicePath}/mysql
rm -f /etc/my.cnf
elif [ "${service}" = "httpd" ]; then
rm -rf ${servicePath}/apache
elif [ "${service}" = "memcached" ]; then
rm -rf /usr/local/memcached
elif [ -d "${servicePath}/${service}" ]; then
rm -rf ${servicePath}/${service}
fi
rm -f /etc/init.d/${service}
echo -e ${service} "\033[32mclean\033[0m"
fi
done
[ -d "${servicePath}/php" ] && rm -rf ${servicePath}/php
if [ -d "${servicePath}/phpmyadmin" ]; then
rm -rf ${servicePath}/phpmyadmin
echo -e "phpmyadmin" "\033[32mclean\033[0m"
fi
if [ -d "${servicePath}/nvm" ]; then
source /www/server/nvm/nvm.sh
pm2 stop all
rm -rf ${servicePath}/nvm
sed -i "/NVM/d" /root/.bash_profile
sed -i "/NVM/d" /root/.bashrc
echo -e "node.js" "\033[32mclean\033[0m"
fi
echo "清除面板运行环境完毕"
}
Remove_Data(){
rm -rf /www/server/data
rm -rf /www/wwwlogs
rm -rf /www/wwwroot
}
#echo -e "What you want to do ?(Default:1)"
echo "1) 卸载宝塔"
echo "2) 卸载宝塔及运行环境(可能影响站点、数据库及其他数据)"
echo "3) 卸载宝塔及运行环境并清除所有站点相关数据(强烈推荐)"
echo "*请检查安全类软件是否关闭,否正可能导致无法正常卸载 "
echo "================================================="
read -p "请选择你要进行的操作(1-3 默认:1): " action;
case $action in
'1')
Remove_Bt
;;
'2')
if [ -f "/usr/bin/yum" ] && [ -f "/usr/bin/rpm" ]; then
Remove_Rpm
fi
Remove_Service
Remove_Bt
;;
'3')
Remove_Rpm
Remove_Service
Remove_Bt
Remove_Data
;;
*)
Remove_Bt
;;
esac