-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop.sh
69 lines (61 loc) · 1.37 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
# Setting color variables to customize the output
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
function text_to_grey () {
tput setaf 240
}
function error_treatment () {
if [ $? -ne 0 ]
then
echo "${red}ERROR${reset} on ${yellow}$current_action${reset} removal. Already deleted?"
else
echo "${green}$current_action deleted...${reset}"
fi
}
# Remove nginx container
current_action="Nginx container"
echo "
Stopping and removing $current_action..."
text_to_grey
docker rm pfa-nginx -f
error_treatment
# Remove MySQL container
current_action="MySQL container"
echo "
Stopping and removing $current_action..."
text_to_grey
docker rm pfa-mysql -f
error_treatment
# Remove NodeJS container
current_action="NodeJS container"
echo "
Stopping and removing $current_action..."
text_to_grey
docker rm pfa-node -f
error_treatment
# Remove docker network
current_action="Docker network"
echo "
Removing network..."
text_to_grey
docker network rm pfa
error_treatment
# Remove images
read -p "
Do you want to remove the images created on start.sh? (y/N) " -n 1 -r choice
echo
if [[ $choice =~ ^[Yy]$ ]]
then
echo "Removing images..."
text_to_grey
docker image rm dnbtr/pfa-node
docker image rm dnbtr/pfa-mysql
docker image rm dnbtr/pfa-nginx
else
echo "Images won't be removed."
fi
echo "
${green}All done.${reset}
"