File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ if [ -d " $1 " ]; then
4
+ cd " $1 "
5
+ else
6
+ echo " Usage: $0 <datadir>" >&2
7
+ echo " Removes obsolete Bitcoin database files" >&2
8
+ exit 1
9
+ fi
10
+
11
+ LEVEL=0
12
+ if [ -f wallet.dat -a -f addr.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=1; fi
13
+ if [ -f wallet.dat -a -f peers.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=2; fi
14
+ if [ -f wallet.dat -a -f peers.dat -a -f coins/CURRENT -a -f blktree/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=3; fi
15
+ if [ -f wallet.dat -a -f peers.dat -a -f chainstate/CURRENT -a -f blocks/index/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=4; fi
16
+
17
+ case $LEVEL in
18
+ 0)
19
+ echo " Error: no Bitcoin datadir detected."
20
+ exit 1
21
+ ;;
22
+ 1)
23
+ echo " Detected old Bitcoin datadir (before 0.7)."
24
+ echo " Nothing to do."
25
+ exit 0
26
+ ;;
27
+ 2)
28
+ echo " Detected Bitcoin 0.7 datadir."
29
+ ;;
30
+ 3)
31
+ echo " Detected Bitcoin pre-0.8 datadir."
32
+ ;;
33
+ 4)
34
+ echo " Detected Bitcoin 0.8 datadir."
35
+ ;;
36
+ esac
37
+
38
+ FILES=" "
39
+ DIRS=" "
40
+
41
+ if [ $LEVEL -ge 3 ]; then FILES=$( echo $FILES blk???? .dat blkindex.dat) ; fi
42
+ if [ $LEVEL -ge 2 ]; then FILES=$( echo $FILES addr.dat) ; fi
43
+ if [ $LEVEL -ge 4 ]; then DIRS=$( echo $DIRS coins blktree) ; fi
44
+
45
+ for FILE in $FILES ; do
46
+ if [ -f $FILE ]; then
47
+ echo " Deleting: $FILE "
48
+ rm -f $FILE
49
+ fi
50
+ done
51
+
52
+ for DIR in $DIRS ; do
53
+ if [ -d $DIR ]; then
54
+ echo " Deleting: $DIR /"
55
+ rm -rf $DIR
56
+ fi
57
+ done
58
+
59
+ echo " Done."
You can’t perform that action at this time.
0 commit comments