-
Notifications
You must be signed in to change notification settings - Fork 1
/
clean
executable file
·61 lines (51 loc) · 1.13 KB
/
clean
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
#!/bin/bash
# Author : Doeraene Anthony
ask_confirmation(){
msg=$1
yes=$2
no=$3
echo "$msg [Y/N]"
read resp
# convert to lower case
resp=${resp,,}
if [ "$resp" == "y" ]; then
$yes
else
$no
fi
}
is_red_hat(){
test -f /etc/redhat-release
}
is_fedora(){
test -n "$(cat /etc/os-release | grep fedora)"
}
enable_firewall(){
echo "Restarting firewall..."
sudo systemctl start firewalld
}
# delete the created files
rm -rf lab/client1
rm -rf lab/client2
rm -rf lab/server1
rm -rf lab/server2
rm -rf lab/main
rm -rf lab/router1
rm -rf lab/router2
rm lab/server1.logs 2> /dev/null
rm lab/server2.logs 2> /dev/null
sudo rm -rf lab/shared
# shutdown kathara
cd lab && sudo kathara lclean
if [ "$?" -ne 0 ]; then
echo "Failed to shutdown lab, try the following commands, or just restart docker:
sudo systemctl restart docker
cd lab && sudo kathara lclean
"
fi
if is_red_hat || is_fedora ; then
echo "Fedora/Red-hat system detected"
ask_confirmation "Do you want to start again your firewall ?" \
'enable_firewall' \
':' # do nothing if don't accept
fi