-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.sh
executable file
·67 lines (55 loc) · 1.56 KB
/
clean.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
#!/bin/bash
# Analyze if the script has been run with sudo
function SudoAnalyze
{
if [ "$EUID" -ne 0 ]; then
echo "Thanks to run the script with sudo."
TerminateScript
fi
}
function OptionsAnalyze
{
# Initialise une variable pour suivre si une option a été traitée
local optionProcessed=0
while [ "$1" != "" ]; do
OPTION=$1
shift
case $OPTION in
-h | --help) optionProcessed=1 && DisplayHelp && TerminateScript;;
-f | --force) optionProcessed=1 && DeleteAll;;
*) echo "Unknown option: $OPTION, please do --help for availables options"; TerminateScript;;
esac
done
# Delete by default
if [ $optionProcessed -eq 0 ]; then
Delete
fi
}
function DisplayHelp
{
echo "-h | --help ........ To obtain some help about the script"
echo "-f | --force ....... To force the suppression of all volumes (directories which store data)"
}
function Delete
{
# Delete docker compose and volumes for blockchain
docker compose --profile pos down
docker compose --profile poa down
docker compose --profile metrics down
rm -Rf ./consensus/beacondata ./consensus/validatordata ./consensus/genesis.ssz
rm -Rf ./execution/geth
}
function DeleteAll
{
echo "Delete volumes for Prometheus and Grafana and Portainer "
docker compose down -v
rm -Rf ./consensus/beacondata ./consensus/validatordata ./consensus/genesis.ssz
rm -Rf ./execution/geth
}
function TerminateScript
{
exit 1
}
# Main Actions
SudoAnalyze
OptionsAnalyze "$@"