-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
281 lines (251 loc) · 8.47 KB
/
Copy pathuninstall.sh
File metadata and controls
281 lines (251 loc) · 8.47 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
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
#! /bin/bash
LOG=/tmp/uninstall_`date "+%m%d%Y_%H_%M_%S"`.log
PKG_Name=`rpm -aq|grep -i occm`
val1=y
val2=n
#if [ -f $LOG ];then
# sudo rm -rf $LOG
#fi
echo "Starting Un-install `date` Log File: $LOG" | tee -a $LOG
if [ -z $PKG_Name ];then
echo "Occm not installed"|tee -a $LOG
if [ ! -d /backup/logs ]; then
sudo mkdir -p /backup/logs
sudo chmod 755 /backup/logs
fi
exit 1
fi
declare -l string=$1
case $string in
silent )
silent=1
;;
esac
function oscheck {
cat /etc/*release*|grep "Amazon Linux 2" > /dev/null
if [ $? -eq 0 ]; then
AMZNLinux=1
fi
return
}
function uninstall {
echo "Please make sure to take a backup before uninstalling existing NetApp OnCommand Cloud Manager,"
echo -en "Type \e[1m'Y'\e[0m to continue with uninstall or \e[1m'N'\e[0m to go back and take a backup: "
read input
declare -l str=$input
while [[ "$str" != $val1 && "$str" != $val2 ]];do
echo -n "ERROR: Must Enter [Y / N]: "
read str
done
if [ $str == y ];then
echo -n "Are you sure you want to completely remove NetApp OnCommand Cloud Manager? [Y / N]: "
read input1
declare -l str1=$input1
while [[ "$str1" != $val1 && "$str1" != $val2 ]];do
echo -n "ERROR: Must Enter [Y / N]: "
read str1
done
if [ $str1 == y ];then
sudo rpm -e $PKG_Name | tee -a $LOG
sudo rpm -aq|grep -i occm
sudo rm -f /etc/yum.repos.d/my.repo
sudo yum clean all
if [ $? == 1 ];then
echo "***** Netapp OnCommand Cloud Manager was successfully removed from you computer *****" | tee -a $LOG
fi
echo -n "Do you wish to remove all the components installed by NetApp OnCommand Cloud Manager (awscli, tridentctl, kubectl, p7zip, Squid, MySQL and Java 1.8 applications, docker) from your computer? [Y / N]: "
read input2
declare -l str2=$input2
while [[ "$str2" != $val1 && "$str2" != $val2 ]];do
echo -n "ERROR: Must Enter [Y / N]: "
read str2
done
if [ $str2 == y ];then
if [[ $AMZNLinux -eq 0 ]];then
sudo yum remove -y docker
sudo rm -f /usr/local/bin/docker-compose
echo " ***** Docker was successfully removed from you computer *****" | tee -a $LOG
fi
if [[ $AMZNLinux -ne 1 ]];then
yum makecache fast >> $LOG
sudo docker stop $(docker ps -a -q)
sudo docker rm $(docker ps -a -q)
sudo rm -rf /usr/local/aws
sudo rm -f /usr/bin/aws
echo "***** awscli was successfully removed removed from you computer *****" | tee -a $LOG
fi
sudo rm -rf /usr/bin/tridentctl
echo "***** tridentctl was successfully removed removed from you computer *****" | tee -a $LOG
sudo rm -rf /usr/bin/kubectl >> $LOG
echo "***** kubectl was successfully removed removed from you computer *****" | tee -a $LOG
#sudo yum -y remove mysql-community-server >> $LOG
sudo yum-complete-transaction >> $LOG
sudo yum -y remove mysql-community-common >> $LOG
sudo yum -y remove mysql-community-release >> $LOG
#sudo yum -y remove mysql-community-client >> $LOG
sudo rm -Rf /var/lib/mysql
sudo rm -Rf /usr/share/mysql
sudo rpm -aq|grep -i mysql
if [ $? == 1 ];then
echo "***** MySQL was successfully removed removed from you computer *****" | tee -a $LOG
fi
sudo yum -y remove java-1.8.0-openjdk >> $LOG
sudo yum -y remove java-1.8.0-openjdk-headless >> $LOG
sudo rpm -aq|grep -i java-1.8.0-openjdk
if [ $? == 1 ];then
echo "***** Java 1.8 was successfully removed removed from you computer *****" | tee -a $LOG
fi
if [[ $AMZNLinux -ne 1 ]];then
sudo yum -y remove createrepo >> $LOG
sudo yum -y remove deltarpm >> $LOG
cd /tmp/
sudo rpm -qa |egrep "deltarpm|createrepo"
if [ $? == 1 ];then
echo "***** CreateRepo was successfully removed from you computer *****" | tee -a $LOG
fi
sudo yum -y remove docker-ce >> $LOG
sudo yum -y remove container-selinux >> $LOG
sudo yum -y remove docker-ce-cli >> $LOG
sudo rm -f /usr/local/bin/docker-composea
cd /tmp/
sudo rpm -qa |egrep "docker-ce|container-selinux"
if [ $? == 1 ];then
echo "***** Docker was successfully removed from you computer *****" | tee -a $LOG
fi
fi
sudo yum -y erase 'p7zip*' >> $LOG
sudo rpm -aq|grep -i p7zip
if [ $? == 1 ];then
echo "***** p7zip was successfully removed removed from you computer *****" | tee -a $LOG
fi
sudo yum -y remove squid >> $LOG
sudo yum -y remove squid-migration-script >> $LOG
sudo rpm -aq|grep -i squid
if [ $? == 1 ];then
echo "***** Squid was successfully removed removed from you computer *****" | tee -a $LOG
fi
#sudo yum -y erase wget >> $LOG
#sudo rpm -aq|grep -i wget
#if [ $? == 1 ];then
# echo "***** wget was successfully removed removed from you computer *****" | tee -a $LOG
#fi
fi
elif [ $str1 == n ];then
if [ ! -d /backup/logs ]; then
sudo mkdir -p /backup/logs
sudo chmod 755 /backup/logs
fi
sudo /bin/cp -rf $LOG /backup/logs
exit 2
fi
elif [ $str == n ];then
if [ ! -d /backup/logs ]; then
sudo mkdir -p /backup/logs
sudo chmod 755 /backup/logs
fi
sudo /bin/cp -rf $LOG /backup/logs
exit 3
fi
}
function uninstallsilent {
echo "Uninstall using silent mode" >> $LOG
if [[ $AMZNLinux -ne 1 ]];then
sudo rpm -e $PKG_Name
sudo rm -f /etc/yum.repos.d/my.repo
sudo yum clean all
sudo docker stop $(docker ps -a -q)
sudo docker rm $(docker ps -a -q)
sudo rpm -aq|grep -i occm
if [ $? == 1 ];then
echo "***** Netapp OnCommand Cloud Manager was successfully removed from your computer *****"| tee -a $LOG
fi
yum makecache fast >> $LOG
sudo rm -rf /usr/local/aws
sudo rm -f /usr/bin/aws
echo "***** awscli was successfully removed from your computer *****" | tee -a $LOG
fi
sudo rm -rf /usr/bin/tridentctl
echo "***** tridentctl was successfully removed removed from you computer *****" | tee -a $LOG
sudo rm -rf /usr/bin/kubectl >> $LOG
echo "***** kubectl was successfully removed removed from you computer *****" | tee -a $LOG
#sudo yum -y remove mysql-community-server >> $LOG
sudo yum-complete-transaction >> $LOG
sudo yum -y remove mysql-community-common >> $LOG
sudo yum -y remove mysql-community-release >> $LOG
#sudo yum -y remove mysql-community-client >> $LOG
sudo rm -Rf /var/lib/mysql
sudo rm -Rf /usr/share/mysql
sudo rpm -aq|grep -i mysql
if [ $? == 1 ];then
echo "***** MySQL was successfully removed from your computer *****" | tee -a $LOG
fi
sudo yum -y remove java-1.8.0-openjdk >> $LOG
sudo yum -y remove java-1.8.0-openjdk-headless >> $LOG
sudo rpm -aq|grep -i java-1.8.0-openjdk
if [ $? == 1 ];then
echo "***** Java 1.8 was successfully removed from your computer *****" | tee -a $LOG
fi
sudo yum -y erase 'p7zip*' >> $LOG
sudo rpm -aq|grep -i p7zip
if [ $? == 1 ];then
echo "***** p7zip was successfully removed from your computer *****" | tee -a $LOG
fi
if [[ $AMZNLinux -eq 0 ]];then
sudo yum remove -y docker
sudo rm -f /usr/local/bin/docker-compose
echo " ***** Docker was successfully removed from you computer *****" | tee -a $LOG
fi
if [[ $AMZNLinux -ne 1 ]];then
sudo yum -y remove createrepo >> $LOG
sudo yum -y remove deltarpm >> $LOG
cd /tmp/
sudo rpm -qa|egrep "deltarpm|createrepo"
if [ $? == 1 ];then
echo " ***** CreateRepo was successfully removed from you computer *****" | tee -a $LOG
fi
sudo yum -y remove docker-ce >> $LOG
sudo yum -y remove container-selinux >> $LOG
sudo yum -y remove docker-ce-cli >> $LOG
cd /tmp/
sudo rpm -qa|egrep "docker-ce|container-selinux"
sudo rm -f /usr/local/bin/docker-composea
sudo rm -f /etc/yum.repos.d/my.repo
if [ $? == 1 ];then
echo " ***** Docker was successfully removed from you computer *****" | tee -a $LOG
fi
fi
#sudo yum -y erase wget >> $LOG
#sudo rpm -aq|grep -i wget
#if [ $? == 1 ];then
# echo "***** wget was successfully removed from your computer *****" | tee -a $LOG
#fi
}
function removeenv {
sudo sed -i '/OCCM_/d' /etc/environment
return
}
function copylog {
if [ ! -d /backup/logs ]; then
sudo mkdir -p /backup/logs
sudo chmod 755 /backup/logs
fi
sudo /bin/cp -rf $LOG /backup/logs
return
}
function removeservicemanager {
sudo systemctl stop service-manager
sudo systemctl disable service-manager
sudo systemctl daemon-reload
sudo rm -Rf /usr/lib/systemd/scripts/service-manager
sudo rm -Rf /usr/lib/systemd/system/service-manager.service
return
}
if [[ $silent -ne 1 ]];then
uninstall
fi
if [[ $silent -eq 1 ]];then
uninstallsilent
fi
removeenv
copylog
removeservicemanager