forked from ActorForth/bch-devsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean
executable file
·106 lines (89 loc) · 2.63 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
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
#!/usr/bin/env bash
set -e
BTK_CERTS=0
BTK_WALLET=0
BTK_WALLET_APP=0
BTK_DOCKER=0
BTK_OPENSIGHT=0
DID_SOMETHING=0
# Process user arguments, or display usage message
if [[ ! -z $1 ]]; then
for var in "$@"
do
[[ $var == "certs" ]] && BTK_CERTS=1
[[ $var == "wallet" ]] && BTK_WALLET=1
[[ $var == "wallet-app" ]] && BTK_WALLET_APP=1
[[ $var == "docker" ]] && BTK_DOCKER=1
if [[ $var == "all" ]]; then
BTK_CERTS=1
BTK_WALLET=1
BTK_WALLET_APP=1
BTK_DOCKER=1
fi
done
else
echo "usage: clean [command]"
echo "- all: cleans every item of all other commands listed here"
echo "- certs: removes only the SSL certifications"
echo "- wallet: removes wallet files in your home directory"
echo "- wallet-app: removes the Electron Cash SLP wallet folder"
echo "- docker: removes the docker containers created by setup"
exit 0
fi
if [[ -d "./configs/cert" && $BTK_CERTS == 1 ]]; then
echo "Removing certificates directory."
rm -rf cert
DID_SOMETHING=1
fi
if [[ -d "./Electron-Cash-SLP" && $BTK_WALLET_APP == 1 ]]; then
echo "Removing Electron-Cash-SLP directory."
rm -rf Electron-Cash-SLP
DID_SOMETHING=1
fi
BTK_ENV=`uname`
if [[ $BTK_ENV == "Darwin" ]];then
ECW_HOME_DIR="/Users/`whoami`/.electron-cash"
fi
if [[ $BTK_ENV == "Linux" || $BTK_ENV == "FreeBSD" ]];then
ECW_HOME_DIR="/home/`whoami`/.electron-cash"
fi
if [[ BTK_WALLET == 1 ]]; then
# This removes wallet from users home folder. Once users are switches over to the
# portable wallet, this part won't be necessary.
if [[ -d "$ECW_HOME_DIR/testnet" ]]; then
while true; do
echo "This script is going to DELETE your electron-wallet directory in your home folder."
read -p "Continue? [Y/n] " yn
case $yn in
[Yy]* ) echo "Removing Electron Cash SLP wallet directory in user's home folder" && rm -rf "$ECW_HOME_DIR/testnet" && DID_SOMETHING=1 && break;;
[Nn]* ) echo "Okay." && break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
if [[ -d "./Electron-Cash-SLP/electron_cash_data" ]]; then
echo "Removing portable electron wallet"
rm -rf "./Electron-Cash-SLP/electron_cash_data"
DID_SOMETHING=1
fi
fi
if [[ $BTK_DOCKER == 1 && -f "./.lock" ]]; then
echo "Removing previous docker containers"
docker-compose down
# Remove node data files
echo "Deleting node data... (./data/bitcoind)"
rm -rf "./data/bitcoind"
# Remove SLPDB data files
echo "Deleting SLPDB data... (./data/mongodb)"
rm -rf "./data/mongodb"
# Remove indexer data files
# echo "Deleting indexer data... (./data/fulcrum)"
# rm -rf "./data/fulcrum"
rm ".lock"
DID_SOMETHING=1
fi
if [ $DID_SOMETHING -eq 1 ]; then
echo "Done."
else
echo "Nothing to do."
fi