-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup.sh
executable file
·54 lines (45 loc) · 944 Bytes
/
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
#!/bin/bash
if [[ ! $(whoami) = "root" ]]
then
echo "Usage: Must be root"
exit 1
fi
if [[ ! -z "$(virsh list --all | grep dns_dns )" ]]
then
cd run/dns
vagrant destroy
cd ../..
fi
if [[ ! -z "$(virsh list --all | grep nfs_nfs )" ]]
then
cd run/nfs
vagrant destroy
cd ../..
fi
if [[ ! -z "$(virsh list --all | grep vpn_vpn )" ]]
then
cd run/vpn
vagrant destroy
cd ../..
fi
if [[ ! -z "$(virsh list --all | grep main_main )" ]]
then
cd run/main
vagrant destroy
cd ../..
fi
while [[ ! -z "$(virsh list --all | grep worker )" ]]
do
WORKER=$(virsh list --all | grep worker | tr -s ' ' | cut -d ' ' -f3 | cut -d_ -f1 )
cd run/$WORKER
vagrant destroy
cd ../..
done
while true; do
read -p "Do you wish to remove the run folder?" yn
case $yn in
[Yy]* ) rm -r run; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done