-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcleanup.sh
executable file
·84 lines (70 loc) · 2.65 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
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
84
#!/bin/bash
# Variables for log colors
YELLOW="\033[0;33m"
GREEN="\033[0;32m"
NC="\033[0m"
cleanUpBromeliaHss() {
echo -e "${GREEN}$(date +%d/%m/%Y) - $(date +%T) - Clean Up Bromélia HSS ${NC}"
echo
#: Cleaning up hss_app containers
if [[ $(docker container ls -a | grep hss_app | wc -l) -gt 0 ]]; then
echo "Cleaning up hss_app containers"
docker container stop $(docker container ls -a | grep hss_app | awk '{print $1}')
docker container rm -f $(docker container ls -a | grep hss_app | awk '{print $1}')
else
echo "There is no hss_app containers to clean up"
fi
#: Cleaning up hss_app images
if [[ $(docker image ls | grep hss_app | wc -l) -gt 0 ]]; then
echo "Cleaning up hss_app images"
docker image rm -f $(docker image ls | grep hss_app | awk '{print $3}')
else
echo "There is no hss_app images to clean up"
fi
#: Cleaning up hss_app networks
if [[ $(docker network ls | grep hss_app | wc -l) -gt 0 ]]; then
echo "Cleaning up hss_app networks"
docker network rm $(docker network ls | grep hss_app | awk '{print $1}')
else
echo "There is no hss_app networks to clean up"
fi
echo
}
cleanUpZabbix() {
echo -e "${GREEN}$(date +%d/%m/%Y) - $(date +%T) - Clean Up Zabbix ${NC}"
echo
#: Cleaning up zabbix containers
if [[ $(docker container ls -a | grep zabbix | wc -l) -gt 0 ]]; then
echo "Cleaning up zabbix containers"
docker container stop $(docker container ls -a | grep zabbix-docker | awk '{print $1}')
docker container rm -f $(docker container ls -a | grep zabbix-docker | awk '{print $1}')
else
echo "There is no zabbix containers to clean up"
fi
#: Cleaning up zabbix images
if [[ $(docker image ls | grep zabbix | wc -l) -gt 0 ]]; then
echo "Cleaning up zabbix images"
docker image rm -f $(docker image ls | grep zabbix | awk '{print $3}')
else
echo "There is no zabbix images to clean up"
fi
#: Cleaning up zabbix networks
if [[ $(docker network ls | grep zbx_net | wc -l) -gt 0 ]]; then
echo "Cleaning up zabbix networks - "
docker network rm $(docker network ls | grep zbx_net | awk '{print $1}')
else
echo "There is no zabbix networks to clean up"
fi
if [[ $(docker network ls | grep zabbix | wc -l) -gt 0 ]]; then
echo "Cleaning up zabbix networks: zabbix-docker_default"
docker network rm $(docker network ls | grep zabbix | awk '{print $1}')
else
echo "There is no zabbix networks to clean up"
fi
echo
}
main() {
cleanUpBromeliaHss
cleanUpZabbix
}
main