-
Notifications
You must be signed in to change notification settings - Fork 5
/
clean
executable file
·70 lines (58 loc) · 1.67 KB
/
clean
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
#!/usr/bin/env bash
set -u
greentext() {
printf "\x1B[32m%b\e[0m\n" "$1"
}
successOrFail() {
if [[ $1 == 0 ]]; then
greentext $2
else
redtext $3
echo $4
exit 1
fi
}
deleteIfExists() {
if [[ -f "$2" || -d "$2" ]]; then
printf "Removing $1 ... "
rm -rf $2
successOrFail $? 'done' 'error' 'Could not remove file.'
DID_SOMETHING=1
fi
}
DID_SOMETHING=0
for var in "$@"
do
if [[ $var == "all" ]]; then
echo "Psst.. Btw, no need to type 'all' anymore. The ./clean script is magically smart =)"
fi
done
if [[ -f "./.lock" ]]; then
printf "docker-compose down\t... "
eval "docker-compose down"
successOrFail $? 'done' 'error' 'Could not docker-compose down.'
DID_SOMETHING=1
fi
# Remove node data files
deleteIfExists "noda data" "./data/bitcoind"
# Remove SLPDB data files
deleteIfExists "SLPDB data" "./data/mongodb"
# Remove indexer data files
deleteIfExists "indexer data" "./data/fulcrum"
# Remove smartbch data
deleteIfExists "SmartBCH data" "./data/smartbchd"
# Remove config file and lock
deleteIfExists "config file" "./config.json"
deleteIfExists "config file" "./configs/bitcoin-unlimited.conf"
deleteIfExists "config file" "./configs/bitcoincashnode.conf"
deleteIfExists "config file" "./configs/temp-fulcrum-config.conf"
deleteIfExists "config file" "./configs/env.env"
deleteIfExists "docker-compose" "./docker-compose.yml"
deleteIfExists "docker-compose.smartbch" "./docker-compose.smartbch.yml"
deleteIfExists "lock" "./.lock"
deleteIfExists "openssl certificate" "./configs/cert"
if [[ $DID_SOMETHING == 1 ]]; then
printf "Finished\n"
else
printf "Nothing to do.\n"
fi