mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
a7a3ecc354
13a81b19d
Add quotes to variable assignment (as requested by @TheBlueMatt) (practicalswift)683b9d280
Fix valid path output (practicalswift)193c2fb4c
Use bash instead of POSIX sh. POSIX sh does not support arrays. (practicalswift)80f5f28d3
Fix incorrect quoting of quotes (the previous quotes had no effect beyond unquoting) (practicalswift)564a172df
Add required space to [[ -n "$1" ]] (previously [[ -n"$1" ]]) (practicalswift)1e44ae0e1
Add error handling: exit if cd fails (practicalswift)b9e79ab41
Remove "\n" from echo argument. echo does not support escape sequences. (practicalswift)f6b3382fa
Remove unused variables (practicalswift) Pull request description: Shell script cleanups: * Add required space to `[ -n ]`. * Avoid quote within quote. * Exit if `cd` fails. * Remove `\n` which is not handled by `echo`. * ~~Remove redundant `$` in arithmetic variable expression.~~ * ~~Use `$(command)` instead of legacy form `` `command` ``.~~ * Arrays are not supported in POSIX `sh`. Use `bash` when arrays are used. * ~~`[ foo -a bar ]` is not well defined, use `[ foo ] && [ bar ]` instead.~~ * ~~`[ foo -o bar ]` is not well defined, use `[ foo ] || [ bar ]` instead.~~ Tree-SHA512: 80f6ded58bce625b15b4da30d69d2714c633e184e62b21ed67d2c58e2ebaa08b4147593324012694d02bf4f1f252844cdff2fd1cf5e817ddb07e2777db7a6390
63 lines
1.5 KiB
Bash
Executable File
63 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright (c) 2013 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
if [ -d "$1" ]; then
|
|
cd "$1" || exit 1
|
|
else
|
|
echo "Usage: $0 <datadir>" >&2
|
|
echo "Removes obsolete Dash database files" >&2
|
|
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)
|
|
echo "Error: no Dash datadir detected."
|
|
exit 1
|
|
;;
|
|
1)
|
|
echo "Detected old Dash datadir (before 0.7)."
|
|
echo "Nothing to do."
|
|
exit 0
|
|
;;
|
|
2)
|
|
echo "Detected Dash 0.7 datadir."
|
|
;;
|
|
3)
|
|
echo "Detected Dash pre-0.8 datadir."
|
|
;;
|
|
4)
|
|
echo "Detected Dash 0.8 datadir."
|
|
;;
|
|
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."
|