-
Notifications
You must be signed in to change notification settings - Fork 2
/
cleanup.sh
executable file
·52 lines (41 loc) · 1.45 KB
/
cleanup.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
#!/bin/sh
function cleanup_all {
services=$(systemctl list-unit-files | grep -E "(redis|mariadb|openstack|neutron|rabbitmq-server).*\s+enabled" | cut -d" " -f1)
for s in $services; do
systemctl stop $s
systemctl disable $s;
done
for x in $(virsh list --all | grep instance- | awk '{print $2}'); do
virsh destroy $x
virsh undefine $x
done
systemctl stop iptables.service
iptables-save > /etc/sysconfig/iptables
yum remove -y puppet "*ntp*" httpd "rabbitmq-server*" \
"redis*" "*openstack*" "*neutron*" "*nova*" "*keystone*" \
"*glance*" "*cinder*" "*heat*" "*ceilometer*" openvswitch \
"*mariadb*" "*mongo*" "*memcache*" perl-DBI perl-DBD-MySQL \
scsi-target-utils iscsi-initiator-utils \
"rdo-release-*"
for x in nova glance cinder keystone horizon neutron heat ceilometer;do
rm -rf /var/lib/$x /var/log/$x /etc/$x
done
rm -rf /root/.my.cnf /var/lib/mysql \
/etc/openvswitch /var/log/openvswitch
if vgs cinder-volumes; then
vgremove -f cinder-volumes
fi
for x in $(losetup -a | sed -e 's/:.*//g'); do
losetup -d $x
done
}
# main
echo "This will completely uninstall all openstack-related components."
echo -n "Are you really sure? (yes/no) "
read answer
if [[ $answer == "yes" ]]; then
cleanup_all 2>/dev/null
echo "Finished. Reboot the server to refresh processes."
else
echo "Cancelled."
fi