93289012ced1198ee0c78db87c0cb8e93aa1473d
[yaml_builds.git] / tools / 0cleanup.sh
1 #!/usr/bin/env bash
2 ##############################################################################
3 # Copyright © 2018 AT&T Intellectual Property. All rights reserved.          #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may    #
6 # not use this file except in compliance with the License.                   #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18
19 read -p "Are you sure you wish to continue? (y/n)" REPLY
20 if [ "$REPLY" != "y" ]; then
21    echo "Good Bye"
22    exit
23 fi
24
25 set -x
26
27 # Check that we are root
28 if [[ $(whoami) != "root" ]]
29 then
30   echo "Must be root to run $0"
31   exit -1
32 fi
33
34 export KUBECONFIG=/etc/kubernetes/admin/kubeconfig.yaml
35
36 kubectl drain --delete-local-data --force $(hostname)
37 systemctl stop kubelet
38 df -lh | awk '{ print $6 }' | grep -i kubelet | xargs -I {} umount -f -l {}
39 df -lh | awk '{ print $6 }' | grep -i docker | grep -v "/var/lib" | xargs -I {} umount -f -l {}
40 umount -f -l /run/user/0
41 mount -a
42 docker rm -fv $(docker ps -aq)
43
44 #systemctl stop docker
45 apt-get remove --autoremove --purge -y docker-engine=1.13.1-0~ubuntu-xenial socat=1.7.3.1-1
46 #Docker
47 rm -rf /dev/docker-data
48 rm -rf /var/lib/docker/*
49 rm -rf /etc/docker
50 rm -rf /etc/systemd/system/docker.service.d
51 rm -rf /var/lib/dockershim
52
53 #Ceph
54 rm -rf /var/lib/openstack-helm
55 rm -rf /var/lib/ceph
56 dd if=/dev/zero of=/dev/sdb  bs=512  count=1 conv=notrunc
57 dd if=/dev/zero of=/dev/sdc  bs=512  count=1 conv=notrunc
58 rm -rf /var/lib/openstack-helm/ceph/journal0/*
59 rm -rf /var/lib/openstack-helm/ceph/journal1/*
60
61 #Kubernetes
62 rm -rf /etc/kubernetes
63 rm -rf /usr/local/bin/kubectl
64 rm -rf /usr/local/bin/kubelet
65 rm -rf /var/lib/kubelet
66 rm -rf /etc/systemd/system/kubelet
67 rm -rf /etc/systemd/system/kubelet.service
68
69 # apt-get install creates the following directory
70 rm -rf /etc/systemd/system/kubelet.service.d/
71 rm -rf /var/log/pods
72 rm -rf /var/log/containers
73
74 #etcd
75 rm -rf /var/lib/auxiliary-etcd-0
76 rm -rf /var/lib/auxiliary-etcd-1
77 rm -rf /var/lib/auxiliary-calico-etcd-0
78 rm -rf /var/lib/auxiliary-calico-etcd-1
79 rm -rf /var/lib/calico-etcd
80 rm -rf /var/lib/kube-etcd
81
82 #nova
83 rm -rf /var/lib/nova/*
84
85 #ONAP
86 rm -rf /dockerdata-nfs/onap/
87 rm -rf /etc/dnsmasq.d
88 rm -rf /opt/cni
89 rm -rf /usr/local/bin/bootstrap
90 rm -rf /usr/local/bin/helm
91 rm -rf /var/lib/prom.done
92
93 # Remove files generated by Promenade
94 rm -rf /etc/cni
95 rm -rf /etc/coredns
96 rm -rf /etc/etcd
97 rm -rf /etc/genesis
98 rm -rf /var/lib/etcd
99 rm -rf /var/lib/kubelet/pods