-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev_cleanup.sh
executable file
·109 lines (90 loc) · 2.19 KB
/
dev_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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cd "$( dirname "$0" )" || return 1
container_tool="_missing"
if [[ $(which docker) && $(docker --version) ]]; then
echo "Docker found"
container_tool="docker"
else
echo "Docker missing but required"
return 1
fi
$container_tool compose down
done=$?
if [ $done -eq 0 ]; then
echo "Docker compose -> down"
fi
echo "Docker image cleanup"
$container_tool image rm docker-php 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: docker-php"
fi
$container_tool image rm c2dl-php 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: c2dl-php"
fi
$container_tool image rm mysql:5.7.28 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: mysql:5.7.28 (old mysql)"
fi
$container_tool image rm mariadb:10.5 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: mariadb:10.5"
fi
$container_tool image rm mariadb:10.11 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: mariadb:10.11"
fi
$container_tool image rm composer/composer:2.7.4 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: composer/composer:2.7.4"
fi
$container_tool image rm httpd:2.4 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: httpd:2.4"
fi
$container_tool image rm node:current-bookworm-slim 2> /dev/null
done=$?
if [ $done -eq 0 ]; then
echo "image removed: node:current-bookworm-slim"
fi
echo "Prune Docker builder cache"
$container_tool builder prune -f
done=$?
if [ $done -eq 0 ]; then
echo "builder cache pruned"
fi
if [ -d ../src/c2dl/node_modules ]; then
rm -r ../src/c2dl/node_modules
echo "Assets: Node modules removed"
fi
if [ -d ../src/c2dl/public/build ]; then
rm -r ../src/c2dl/public/build
echo "Assets: Asset builds removed"
fi
if [ -d ../src/c2dl/vendor ]; then
rm -r ../src/c2dl/vendor
echo "Composer: vendors removed"
fi
if [ -d .run/logs ]; then
rm -r .run/logs
echo "Logs: Docker logs removed"
fi
if [ -d .run/mysql ]; then
dialog --stdout --title "Database removal" \
--backtitle "Database removal" \
--yesno "Do you want to remove the database content?" 7 60
db_remove=$?
clear
else
db_remove=1
fi
if [ $db_remove -eq 0 ]; then
rm -r .run/mysql
echo "Database removed"
fi