forked from centos-bz/ezhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
172 lines (147 loc) · 3.8 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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#===============================================================================
# SYSTEM REQUIRED: Linux
# DESCRIPTION: automatic deploy your linux
# AUTHOR: Zhu Maohai.
# website: http://www.centos.bz/ezhttp/
#===============================================================================
cur_dir=`pwd`
#大写转换成小写
upcase_to_lowcase(){
words=$1
echo $words | tr '[A-Z]' '[a-z]'
}
#判断系统版本
check_sys(){
local checkType=$1
local value=$2
local release=''
local systemPackage=''
local packageSupport=''
if [[ -f /etc/redhat-release ]];then
release="centos"
systemPackage="yum"
packageSupport=true
elif cat /etc/issue | grep -q -E -i "debian";then
release="debian"
systemPackage="apt"
packageSupport=true
elif cat /etc/issue | grep -q -E -i "ubuntu";then
release="ubuntu"
systemPackage="apt"
packageSupport=true
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat";then
release="centos"
systemPackage="yum"
packageSupport=true
elif cat /proc/version | grep -q -E -i "debian";then
release="debian"
systemPackage="apt"
packageSupport=true
elif cat /proc/version | grep -q -E -i "ubuntu";then
release="ubuntu"
systemPackage="apt"
packageSupport=true
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat";then
release="centos"
systemPackage="yum"
packageSupport=true
else
release="unknow"
systemPackage="unknow"
packageSupport=false
fi
if [[ $checkType == "sysRelease" ]]; then
if [ "$value" == "$release" ];then
return 0
else
return 1
fi
elif [[ $checkType == "packageManager" ]]; then
if [ "$value" == "$systemPackage" ];then
return 0
else
return 1
fi
elif [[ $checkType == "packageSupport" ]]; then
if $packageSupport;then
return 0
else
return 1
fi
fi
}
#关闭开机启动
boot_stop(){
if check_sys sysRelease ubuntu || check_sys sysRelease debian;then
update-rc.d -f $1 remove
elif check_sys sysRelease centos;then
chkconfig $1 off
fi
}
uninstall(){
if [ ! -s "/etc/ezhttp_info_do_not_del" ];then
echo "/etc/ezhttp_info_do_not_del not found,uninstall failed."
exit 1
fi
. /etc/ezhttp_info_do_not_del
if [ "$depends_prefix" != "" ];then
echo "removing depends components.."
rm -rf "$depends_prefix" && echo "Sucess"
fi
if [ "$nginx_location" != "" ];then
echo "uninstalling nginx"
service nginx stop
boot_stop nginx
rm -f /etc/init.d/nginx
rm -rf "$nginx_location" && echo "Sucess"
fi
if [ "$apache_location" != "" ];then
echo "uninstalling apache"
service httpd stop
boot_stop httpd
rm -f /etc/init.d/httpd
rm -rf "$apache_location" && echo "Sucess"
fi
if [ "$mysql_location" != "" ];then
echo "uninstalling mysql"
service mysqld stop
boot_stop mysqld
rm -f /etc/init.d/mysqld
rm -rf "$mysql_location" && echo "Sucess"
fi
if [ "$php_location" != "" ];then
echo "uninstalling php"
/etc/init.d/php-fpm stop
boot_stop php-fpm
rm -f /etc/init.d/php-fpm
rm -rf "$php_location" && echo "Sucess"
fi
if [ "$memcached_location" != "" ];then
echo "uninstalling memcached"
service memcached stop
boot_stop memcached
rm -f /etc/init.d/memcached
rm -rf "$memcached_location" && echo "Sucess"
fi
if [ "$pureftpd_location" != "" ];then
echo "uninstalling pureftpd"
service pureftpd stop
boot_stop pureftpd
rm -f /etc/init.d/pureftpd
rm -rf "$pureftpd_location" && echo "Sucess"
fi
chattr -a /etc/ezhttp_info_do_not_del && rm -f /etc/ezhttp_info_do_not_del
}
while true
do
read -p "Are you sure uninstall ezhttp(include nginx apache mysql php memcached pureftpd etc.)? [N/y]? " uninstall
uninstall="`upcase_to_lowcase $uninstall`"
case $uninstall in
y) uninstall ; break;;
n) break;;
*) echo "input error";;
esac
done