-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforchetta.sh
executable file
·52 lines (42 loc) · 1.12 KB
/
forchetta.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
#!/bin/bash
set -eu
[[ $EUID = 0 ]] && SUDO="" || SUDO="sudo"
# remove existing directory
function rm_x_dir() {
[[ -d "$1" ]] && $SUDO rm -rf "$1" || true # true needed to keep running if dir does not exist
}
read -p "Do you want to tear down and clean up everything in this directory? [y/N] " PROCEED
if ! [[ "$PROCEED" = "y" || "$PROCEED" = "Y" ]];then
echo -e "\nAborting...\n"
exit 0
fi
if [[ -d tarallo ]]; then
cd tarallo
if [[ -f Makefile ]]; then
make down
make destroy
fi
cd ..
fi
if [[ -d weeehire-ng ]]; then
cd weeehire-ng
if [[ -f docker-compose.yml ]]; then
docker-compose down
fi
cd ..
fi
read -p "Terminate all xterm processes? [y/N] " PROCEED
if [[ "$PROCEED" = "y" || "$PROCEED" = "Y" ]]; then
echo -e "Terminating all xterm processes...\n"
sudo killall xterm &> /dev/null || true
else
echo -e "Skipping xterm termination...\n"
fi
read -p "Clean up all repo directories? [y/N] " CLEANUP
if [[ "$CLEANUP" = "y" || "$CLEANUP" = "Y" ]]; then
for DIR in tarallo weeehire-ng peracotta pesto sardina; do
echo -e "Removing $DIR directory..."
rm_x_dir $DIR
done
fi
echo -e "\nTeardown complete!\n"