2018-12-05 00:07:58 +01:00
#!/bin/bash
2018-07-29 01:33:54 +02:00
2018-12-06 14:36:02 +01:00
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
2018-07-29 01:33:54 +02:00
2019-01-22 23:26:04 +01:00
# get local ip
localip = $( ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/' )
# create bitcoin base directory and link with bitcoin user
2019-01-23 01:07:26 +01:00
sudo rm -rf /mnt/hdd/bitcoin 2>/dev/null
sudo mkdir /mnt/hdd/bitcoin
2019-01-23 00:52:43 +01:00
sudo chown bitcoin:bitcoin /mnt/hdd/bitcoin
2019-01-22 23:26:04 +01:00
sudo ln -s /mnt/hdd/bitcoin /home/bitcoin/.bitcoin
2019-01-23 14:07:59 +01:00
clear
echo "************************************************************************************"
echo "Instructions to COPY/TRANSFER SYNCED BLOCKCHAIN from another computer"
echo "************************************************************************************"
2018-07-17 13:12:03 +02:00
echo ""
2019-01-22 23:26:04 +01:00
echo "You can use the blockchain from another bitcoin-core client with version greater or equal"
2019-01-23 00:56:08 +01:00
echo "to 0.17.1 with transaction index switched on (txindex=1 in the bitcoin.conf)."
2018-07-17 13:12:03 +02:00
echo ""
2019-01-22 23:26:04 +01:00
echo "Both computers (your RaspberryPi and the other computer with the full blockchain on) need"
echo "to be connected to the same local network."
2018-07-17 13:12:03 +02:00
echo ""
2019-01-23 14:07:59 +01:00
echo "Open a terminal on the source computer and change into the directory that constains the"
2019-01-22 23:26:04 +01:00
echo "blockchain data. You should see directories 'blocks', 'chainstate' & 'indexes'" .
echo "Make sure the bitcoin client on that computer is stopped."
2018-07-17 13:12:03 +02:00
echo ""
2019-01-23 14:07:59 +01:00
echo "COPY, PASTE & EXECUTE the following command on the blockchain source computer:"
echo " sudo scp -r ./chainstate ./indexes ./blocks ./testnet3 bitcoin@ ${ localip } :/home/bitcoin/.bitcoin "
2018-07-17 13:12:03 +02:00
echo ""
2019-01-23 14:07:59 +01:00
echo "This command will ask for your SSH PASSWORD A from this RaspiBlitz."
echo "It can take multiple hours until transfer is complete - be patient."
echo "************************************************************************************"
echo "PRESS ENTER if transfers is done OR if you want to choose another another option."
#echo "Copy, Paste and Execute the following commands - line by line:"
#echo "sudo scp -r ./chainstate bitcoin@${localip}:/home/bitcoin/.bitcoin/chainstate"
#echo "sudo scp -r ./indexes bitcoin@${localip}:/home/bitcoin/.bitcoin/indexes"
#echo "sudo scp -r ./blocks bitcoin@${localip}:/home/bitcoin/.bitcoin/blocks"
#echo ""
#echo "Every command above needs your SSH PASSWORD A to work and will take some time to transfer."
#echo "PRESS ENTER if all 3 transfers are done or if you dont care and you want to return to menu."
2019-01-22 23:26:04 +01:00
read key
2018-07-17 13:12:03 +02:00
2019-01-22 23:26:04 +01:00
# unlink bitcoin user (will created later in setup again)
sudo unlink /home/bitcoin/.bitcoin
# make quick check if data is there
anyDataAtAll = 0
quickCheckOK = 1
2019-01-23 00:47:20 +01:00
count = $( sudo ls /mnt/hdd/bitcoin/blocks 2>/dev/null | grep -c '.dat' )
2019-01-22 23:26:04 +01:00
if [ ${ count } -gt 0 ] ; then
echo "Found data in /mnt/hdd/bitcoin/blocks"
anyDataAtAll = 1
2019-01-23 00:47:20 +01:00
fi
2019-01-22 23:26:04 +01:00
if [ ${ count } -lt 3000 ] ; then
echo " FAIL: transfere seems invalid - less then 3000 .dat files ( ${ count } ) "
quickCheckOK = 0
2018-07-17 13:12:03 +02:00
fi
2019-01-23 00:47:20 +01:00
count = $( sudo ls /mnt/hdd/bitcoin/chainstate 2>/dev/null | grep -c '.ldb' )
2019-01-22 23:26:04 +01:00
if [ ${ count } -gt 0 ] ; then
echo "Found data in /mnt/hdd/bitcoin/chainstate"
anyDataAtAll = 1
fi
2019-01-23 00:45:10 +01:00
if [ ${ count } -lt 1400 ] ; then
2019-01-22 23:26:04 +01:00
echo " FAIL: transfere seems invalid - less then 1400 .ldb files ( ${ count } ) "
quickCheckOK = 0
fi
2019-01-23 00:47:20 +01:00
count = $( sudo ls /mnt/hdd/bitcoin/indexes/txindex 2>/dev/null | grep -c '.ldb' )
2019-01-22 23:26:04 +01:00
if [ ${ count } -gt 0 ] ; then
echo "Found data in /mnt/hdd/bitcoin/indexes/txindex"
anyDataAtAll = 1
fi
if [ ${ count } -lt 5200 ] ; then
echo " FAIL: less then 5200 .ldb files ( ${ count } ) in /mnt/hdd/bitcoin/chainstate (transfere seems invalid) "
quickCheckOK = 0
2018-07-17 13:12:03 +02:00
fi
2019-01-22 23:26:04 +01:00
# just if any data transferred ..
if [ ${ anyDataAtAll } -eq 1 ] ; then
# data was invalkid - ask user to keep?
if [ ${ quickCheckOK } -eq 0 ] ; then
echo "*********************************************"
echo "There seems to be a invalid transfere."
echo "Wait 5 secs ..."
sleep 5
2019-01-23 01:03:03 +01:00
dialog --title " INVALID TRANSFER - DELETE DATA?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. This can lead further RaspiBlitz setup to get stuck in error state.\nDo you want to reset/delete data data?" 8 60
2019-01-22 23:26:04 +01:00
response = $?
echo " response( ${ response } ) "
case $response in
2019-01-23 01:03:03 +01:00
1) quickCheckOK = 1 ; ;
2019-01-22 23:26:04 +01:00
esac
fi
2018-07-17 13:12:03 +02:00
2019-01-22 23:26:04 +01:00
if [ ${ quickCheckOK } -eq 0 ] ; then
echo "Deleting invalid Data ..."
sudo rm -rf /mnt/hdd/bitcoin
sudo rm -rf /home/bitcoin/.bitcoin
sleep 2
fi
else
# when no data transferred - just delete bitcoin base dir again
sudo rm -rf /mnt/hdd/bitcoin
fi
2018-07-17 13:12:03 +02:00
2019-01-22 23:26:04 +01:00
# setup script will decide the next logical step
./10setupBlitz.sh