forked from openshift/microshift
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcleanup.sh
executable file
·53 lines (44 loc) · 1.73 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
52
53
#!/bin/bash
set -eu
echo "DATA LOSS WARNING: Do you wish to stop and cleanup ALL MicroShift data AND cri-o container workloads?"
select yn in "Yes" "No"; do
case "${yn}" in
Yes ) break ;;
* ) echo "aborting cleanup; " ; exit;;
esac
done
# crictl redirect STDOUT. When no objects (pod, image, container) are present, crictl dump the help menu instead. This may be confusing to users.
sudo bash -c '
echo "Stopping microshift"
set +e
systemctl stop --now microshift 2>/dev/null
systemctl disable microshift 2>/dev/null
systemctl stop --now microshift-containerized 2>/dev/null
systemctl disable microshift-containerized 2>/dev/null
docker stop microshift 2>/dev/null
docker stop microshift-aio 2>/dev/null
podman stop microshift 2>/dev/null
podman stop microshift-aio 2>/dev/null
echo "Removing crio pods"
until crictl rmp --all --force 1>/dev/null; do sleep 1; done
echo "Removing crio containers"
crictl rm --all --force 1>/dev/null
echo "Removing crio images"
crictl rmi --all --prune 1>/dev/null
echo "Killing conmon, pause processes"
pkill -9 conmon
pkill -9 pause
echo "Removing /var/lib/microshift"
rm -rf /var/lib/microshift
echo "Unmounting /var/lib/kubelet/pods/..."
mount | grep "^overlay.* on /var/lib/kubelet/pods/" | awk "{print \$3}" | xargs -n1 -r umount
mount | grep "^tmpfs.* on /var/lib/kubelet/pods/" | awk "{print \$3}" | xargs -n1 -r umount
mount | grep "^/dev/.* on /var/lib/kubelet/pods/" | awk "{print \$3}" | xargs -n1 -r umount
rm -rf /var/lib/kubelet/pods/*
rm -rf /var/hpvolumes/*
systemctl stop crio
sleep 2
rm -rf /var/lib/containers/*
systemctl start crio
echo "Cleanup succeeded"
'