-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathecclean_macos
207 lines (202 loc) · 3.75 KB
/
ecclean_macos
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
# alias.sh
D_VERS="0.2.5.10"
alias cls='printf "\033c"'
shopt -s expand_aliases
main () {
echo "Welcome to ECC tools for MacOS"
read -n 1 -s -r -p "Press any key to continue"
}
menu () {
while true; do
echo -e "PLEASE CHOOSE FROM THE FOLLOWING OPTIONS\r\n1 - ECC Version Check\r\n2 - Clear Current Daemon\r\n3 - Clear Banlist and Peers\r\n4 - Clear Data Directory (will not remove wallet files)\r\n5 - Exit"
read choice
echo
case $choice in
1)
cls
version_check
;;
2)
cls
clear_daemon
;;
3)
clear_ban_peer
;;
4)
clear_data
;;
5)
cls
exit
;;
*)
cls
;;
esac
done
}
version_check () {
if [ -d ~/Library/'Application Support'/'.eccoin-wallet' ]; then
cd ~/Library/'Application Support'/'.eccoin-wallet'
if [ -f "wallet-version.txt" ]; then
CUR_D=$(cat 'wallet-version.txt')
echo "ECC Daemon detected - Version: $CUR_D"
echo
elif [ -e "Eccoind.app" ]; then
echo "ECC Daemon detected - Version unknown."
echo
else
echo "ECC Daemon not detected."
echo
fi
else
echo "Directory (/.eccoin-wallet) does not exist."
echo
fi
}
clear_daemon () {
version_check
if [ -d ~/Library/'Application Support'/'.eccoin-wallet' ]; then
while true; do
echo -e "Enter "D" to clear daemon directory.\r\nEnter "E" to return to main menu."
read choice
echo
case $choice in
E)
cls
menu
;;
D)
rm -rf ~/Library/'Application Support'/'.eccoin-wallet' && mkdir ~/Library/'Application Support'/'.eccoin-wallet'
cls
echo "Daemon directory has been cleared."
echo
menu
;;
*)
cls
;;
esac
done
else
cls
echo "Directory (/.eccoin-wallet) does not exist."
echo
menu
fi
}
clear_ban_peer () {
cls
if [ -d ~/Library/'Application Support'/eccoin ]; then
echo "Data directory found."
echo
cd ~/Library/'Application Support'/eccoin/
while true; do
echo -e "Enter "D" to remove banlist.dat and peers.dat\r\nEnter "E" to return to main menu."
read choice
echo
case $choice in
D)
if [ -f "peers.dat" ]; then
rm -rfv peers.dat
fi
if [ -f "banlist.dat" ]; then
rm -rfv banlist.dat
fi
cls
echo "Banlist.dat and peers.dat removed"
echo
menu
;;
E)
cls
menu
;;
*)
cls
;;
esac
done
else
cls
echo "Data directory (/eccoin) does not exist."
echo
menu
fi
}
clear_data () {
cls
if [ -d ~/Library/'Application Support'/eccoin ]; then
echo "Data directory found."
echo
cd ~/Library/'Application Support'/eccoin/
while true; do
echo -e "Enter "D" to clear directory.\r\nEnter "E" to return to main menu."
read choice
echo
case $choice in
D)
if [ -d "blocks" ]; then
rm -rf blocks
fi
if [ -d "chainstate" ]; then
rm -rf chainstate
fi
if [ -d "database" ]; then
rm -rf database
fi
if [ -d "services" ]; then
rm -rf services
fi
if [ -f ".lock" ]; then
rm -rf '.lock'
fi
if [ -f "db.log" ]; then
rm -rf db.log
fi
if [ -f "debug.log" ]; then
rm -rf debug.log
fi
if [ -f "eccoin.conf" ]; then
rm -rf eccoin.conf
fi
if [ -f "eccoind.pid" ]; then
rm -rf eccoind.pid
fi
if [ -f "peers.dat" ]; then
rm -rf peers.dat
fi
if [ -f "banlist.dat" ]; then
rm -rf banlist.dat
fi
if [ -f "fee_estimates.dat" ]; then
rm -rf fee_estimates.dat
fi
cls
echo "Data directory (/eccoin) cleared"
echo
menu
;;
E)
cls
menu
;;
*)
cls
;;
esac
done
else
cls
echo "Data directory (/eccoin) does not exist."
echo
menu
fi
}
cls
main
cls
menu
exit