-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop-and-remove.sh
executable file
·51 lines (49 loc) · 1.59 KB
/
stop-and-remove.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/env bash
# Stop running containers and remove related directories
read -p "Do you really want to stop and remove EVERYTHING (y/n)? " answer
case ${answer:0:1} in
y|Y )
echo "INFO: Stopping containers"
docker-compose stop
echo "INFO: Removing containers"
docker-compose rm -f
echo "INFO: Setting file permissions to that of the user"
docker run --rm \
-v $(pwd):/clean \
-e UID=$(id -u) \
-e GID=$(id -g) \
nginx:latest /bin/bash -c 'chown -R $UID:$GID /clean'
echo "INFO: Pruning unused docker volumes"
docker volume prune -f
echo "INFO: Pruning unused docker networks"
docker network prune -f
echo "INFO: Removing directories and contents (certificates/ logs/nginx mysql/ wordpress/)"
rm -rf certificates/ logs/nginx mysql/ wordpress/ nginx-proxy_conf acme
echo "INFO: Done"
exit 0;
;;
* )
read -p "Do you want to stop only (y/n)? " answer2
case ${answer2:0:1} in
y|Y )
echo "INFO: Stopping containers"
docker-compose stop
echo "INFO: Removing containers"
docker-compose rm -f
echo "INFO: Setting file permissions to that of the user"
docker run --rm \
-v $(pwd):/clean \
-e UID=$(id -u) \
-e GID=$(id -g) \
nginx:latest /bin/bash -c 'chown -R $UID:$GID /clean'
echo "INFO: Done"
exit 0;
;;
* )
echo "INFO: Exiting without stopping containers or removing files"
exit 0;
;;
esac
;;
esac
exit 0;