[tests] Add -blocknotify functional test
[bitcoinplatinum.git] / contrib / tidy_datadir.sh
blob8960f8811d81e883773fc76add0f6421d173df82
1 #!/bin/bash
2 # Copyright (c) 2013 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 if [ -d "$1" ]; then
7 cd "$1"
8 else
9 echo "Usage: $0 <datadir>" >&2
10 echo "Removes obsolete Bitcoin database files" >&2
11 exit 1
14 LEVEL=0
15 if [ -f wallet.dat -a -f addr.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=1; fi
16 if [ -f wallet.dat -a -f peers.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=2; fi
17 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
18 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
20 case $LEVEL in
22 echo "Error: no Bitcoin datadir detected."
23 exit 1
26 echo "Detected old Bitcoin datadir (before 0.7)."
27 echo "Nothing to do."
28 exit 0
31 echo "Detected Bitcoin 0.7 datadir."
34 echo "Detected Bitcoin pre-0.8 datadir."
37 echo "Detected Bitcoin 0.8 datadir."
39 esac
41 FILES=""
42 DIRS=""
44 if [ $LEVEL -ge 3 ]; then FILES=$(echo $FILES blk????.dat blkindex.dat); fi
45 if [ $LEVEL -ge 2 ]; then FILES=$(echo $FILES addr.dat); fi
46 if [ $LEVEL -ge 4 ]; then DIRS=$(echo $DIRS coins blktree); fi
48 for FILE in $FILES; do
49 if [ -f $FILE ]; then
50 echo "Deleting: $FILE"
51 rm -f $FILE
53 done
55 for DIR in $DIRS; do
56 if [ -d $DIR ]; then
57 echo "Deleting: $DIR/"
58 rm -rf $DIR
60 done
62 echo "Done."