2013-02-10 20:49:39 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ -d "$1" ]; then
|
|
|
|
cd "$1"
|
|
|
|
else
|
|
|
|
echo "Usage: $0 <datadir>" >&2
|
2024-12-16 19:40:22 +01:00
|
|
|
echo "Removes obsolete Neobytes database files" >&2
|
2013-02-10 20:49:39 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
LEVEL=0
|
|
|
|
if [ -f wallet.dat -a -f addr.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=1; fi
|
|
|
|
if [ -f wallet.dat -a -f peers.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=2; fi
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
case $LEVEL in
|
|
|
|
0)
|
2024-12-16 19:40:22 +01:00
|
|
|
echo "Error: no Neobytes datadir detected."
|
2013-02-10 20:49:39 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
1)
|
2024-12-16 19:40:22 +01:00
|
|
|
echo "Detected old Neobytes datadir (before 0.7)."
|
2013-02-10 20:49:39 +01:00
|
|
|
echo "Nothing to do."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
2)
|
2024-12-16 19:40:22 +01:00
|
|
|
echo "Detected Neobytes 0.7 datadir."
|
2013-02-10 20:49:39 +01:00
|
|
|
;;
|
|
|
|
3)
|
2024-12-16 19:40:22 +01:00
|
|
|
echo "Detected Neobytes pre-0.8 datadir."
|
2013-02-10 20:49:39 +01:00
|
|
|
;;
|
|
|
|
4)
|
2024-12-16 19:40:22 +01:00
|
|
|
echo "Detected Neobytes 0.8 datadir."
|
2013-02-10 20:49:39 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
FILES=""
|
|
|
|
DIRS=""
|
|
|
|
|
|
|
|
if [ $LEVEL -ge 3 ]; then FILES=$(echo $FILES blk????.dat blkindex.dat); fi
|
|
|
|
if [ $LEVEL -ge 2 ]; then FILES=$(echo $FILES addr.dat); fi
|
|
|
|
if [ $LEVEL -ge 4 ]; then DIRS=$(echo $DIRS coins blktree); fi
|
|
|
|
|
|
|
|
for FILE in $FILES; do
|
|
|
|
if [ -f $FILE ]; then
|
|
|
|
echo "Deleting: $FILE"
|
|
|
|
rm -f $FILE
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for DIR in $DIRS; do
|
|
|
|
if [ -d $DIR ]; then
|
|
|
|
echo "Deleting: $DIR/"
|
|
|
|
rm -rf $DIR
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Done."
|