-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathstop.sh
executable file
·83 lines (73 loc) · 1.56 KB
/
stop.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
#!/bin/bash
usage() {
echo "Usage: $0 [--parallel] [--nopurge] [--skipdb]" 1>&2
}
PARALLEL=""
PURGE="true"
SKIPDB="false"
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--parallel)
shift
PARALLEL="--parallel"
;;
--nopurge)
shift
PURGE=""
;;
--skipdb)
shift
SKIPDB="true"
;;
-help)
usage
exit 0
;;
*)
echo "Error: unexpected argument '$1'"
usage
exit 1
;;
esac
done
if mount | grep -q 9p; then
echo "umount /mnt/9p"
./umount.sh
fi
pgrep -x npproxyd > /dev/null && killall -9 npproxyd
pgrep -x spproxyd > /dev/null && killall -9 spproxyd
sudo rm -f /tmp/spproxyd/spproxyd.sock
sudo rm -f /tmp/spproxyd/spproxyd-dialproxy.sock
if docker ps -a | grep -qE 'sigma|procd|bootkerne|kernel-'; then
for container in $(docker ps -a | grep -E 'sigma|procd|bootkerne|kernel-' | cut -d ' ' -f1) ; do
# Optionally skip DB shutdown
if [ "$SKIPDB" == "true" ]; then
cname=$(docker ps -a | grep $container | cut -d ' ' -f4)
if [ "$cname" == "mariadb" ] || [ "$cname" == "mongo:4.4.6" ]; then
echo "skipping stop db $cname"
continue
fi
fi
stop="
docker stop $container
docker rm $container
"
if [ -z "$PARALLEL" ]; then
eval "$stop"
else
(
eval "$stop"
) &
fi
done
fi
wait
if ! [ -z $PURGE ]; then
yes | docker system prune
yes | docker volume prune
fi
sudo rm -rf /tmp/sigmaos-bin
sudo rm -rf /tmp/sigmaos-kernel-start-logs
# delete all keys from etcd
docker exec etcd-server etcdctl del --prefix ''