-
Notifications
You must be signed in to change notification settings - Fork 0
/
unbuild_cluster.sh
executable file
·53 lines (32 loc) · 1.1 KB
/
unbuild_cluster.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
#!/usr/bin/bash
# The goal of this script is to clean up enough so that `build_cluster.sh` will run correctly.
#
# Note it does some general tidying of docker as well, so if you are
# using this machine for anything else, you should check to make sure
# it doesn't do something you don't want.
# First stop the cluster:
./stop_cluster.sh
# Remove users
userdel -rf jovyan
for W in $WORKER_ADDRS; do ssh $W userdel -f cfiddle;done
# Remove stopped containers
docker container prune
for W in $WORKER_ADDRS; do ssh $W docker container prune;done
docker image prune
for W in $WORKER_ADDRS; do ssh $W docker image prune;done
docker network prune
for W in $WORKER_ADDRS; do ssh $W docker image prune;done
# delete volumes
./delete_volumes.sh
docker volume prune
# cleanup nfs exports and stop nfs.
cp /etc/exports /etc/exports.bak
grep -v cfiddle_cluster < /etc/exports.bak > /etc/exports
exportfs -ra
# Remove munge key
rm -rf /etc/munge
# delete cfiddle and delegate-function
rm -rf cfiddle delegate-function
# Tear down swarm
for W in $WORKER_ADDRS; do ssh $W docker swarm leave -f;done
docker swarm leave -f