Improve Copying Blockchain (#1609)

This commit is contained in:
Christian Rotzoll 2020-10-01 17:30:17 +02:00 committed by rootzoll
parent b125dc8b36
commit b0d1cc5e89
4 changed files with 52 additions and 32 deletions

View file

@ -167,7 +167,8 @@ if [ ${isMounted} -eq 1 ]; then
echo "UNKOWN STATE - there is blockain data config, but blockchain service is not running"
echo "It seems that something went wrong during sync/download/copy of the blockchain."
echo "Or something with the config is not correct."
echo "Sometimes a reboot helps --> sudo shutdown -r now"
echo "Sometimes a reboot helps - use command: restart"
echo "Or try to repair blockchain - use command: repair"
exit 1
else
echo "Got mounted blockchain, but no config and running service yet --> finish HDD"

View file

@ -45,7 +45,7 @@ if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then
fi
if [ ${hasOldBlockchainData} -eq 1 ] && [ "$1" != "stop-after-script" ]; then
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the old/local blockchain data now?" 7 60
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
response=$?
echo "response(${response})"
if [ "${response}" = "1" ]; then
@ -231,6 +231,15 @@ if [ ${quickCheckOK} -eq 0 ]; then
echo "Wait 5 secs ..."
sleep 5
dialog --title " INVALID TRANSFER - TRY AGAIN?" --yesno "Quickcheck shows the data you transferred is invalid/incomplete. Maybe transfere was interrupted and not completed.\n\nDo you want retry/proceed the copy process?" 8 70
response=$?
echo "response(${response})"
if [ "${response}" == "0" ]; then
/home/admin/50copyHDD.sh
exit 0
fi
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?" 8 60
response=$?
echo "response(${response})"

View file

@ -97,9 +97,21 @@ copyHost()
echo "# Starting copy over LAN (around 4-6 hours) ..."
sed -i "s/^state=.*/state=copysource/g" /home/admin/raspiblitz.info
cd /mnt/hdd/${network}
# transfere beginning flag
date +%s > ./copy_begin.time
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' ./copy_begin.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
rm ./copy_begin.time
# transfere blockchain data
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' --info=progress2 ./chainstate ./blocks bitcoin@${targetIP}:/mnt/hdd/bitcoin
sed -i "s/^state=.*/state=/g" /home/admin/raspiblitz.info
# transfere end flag
date +%s > ./copy_end.time
sudo sshpass -p "${targetPassword}" rsync -avhW -e 'ssh -o StrictHostKeyChecking=no -p 22' ./copy_end.time bitcoin@${targetIP}:/mnt/hdd/bitcoin
rm ./copy_end.time
echo "# start services again ..."
sudo systemctl enable ${network}d
sudo systemctl start ${network}d

View file

@ -40,6 +40,15 @@ do
# gather the uptime seconds
upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+')
# prevent restart if COPY OVER LAN is running
# see: https://github.com/rootzoll/raspiblitz/issues/1179#issuecomment-646079467
source ${infoFile}
if [ "${state}" == "copysource" ]; then
echo "copysource mode: skipping background loop"
sleep 10
continue
fi
####################################################
# RECHECK DHCP-SERVER
# https://github.com/rootzoll/raspiblitz/issues/160
@ -142,38 +151,27 @@ do
recheckBlitzTUI=$(($counter % 30))
if [ "${touchscreen}" == "1" ] && [ ${recheckBlitzTUI} -eq 1 ]; then
echo "BlitzTUI Monitoring Check"
# prevent restart if COPY OVER LAN is running
# see: https://github.com/rootzoll/raspiblitz/issues/1179#issuecomment-646079467
source ${infoFile}
if [ "${state}" == "copysource" ]; then
echo "- skip BlitzTUI check while COPY over LAN is running"
if [ -d "/var/cache/raspiblitz" ]; then
latestHeartBeatLine=$(sudo tail -n 300 /var/cache/raspiblitz/pi/blitz-tui.log | grep beat | tail -n 1)
else
if [ -d "/var/cache/raspiblitz" ]; then
latestHeartBeatLine=$(sudo tail -n 300 /var/cache/raspiblitz/pi/blitz-tui.log | grep beat | tail -n 1)
else
latestHeartBeatLine=$(sudo tail -n 300 /home/pi/blitz-tui.log | grep beat | tail -n 1)
fi
if [ ${#blitzTUIHeartBeatLine} -gt 0 ]; then
#echo "blitzTUIHeartBeatLine(${blitzTUIHeartBeatLine})"
#echo "latestHeartBeatLine(${latestHeartBeatLine})"
if [ "${blitzTUIHeartBeatLine}" == "${latestHeartBeatLine}" ]; then
echo "FAIL - still no new heart beat .. restarting BlitzTUI"
blitzTUIRestarts=$(($blitzTUIRestarts +1))
if [ $(sudo cat /home/admin/raspiblitz.info | grep -c 'blitzTUIRestarts=') -eq 0 ]; then
echo "blitzTUIRestarts=0" >> /home/admin/raspiblitz.info
fi
sudo sed -i "s/^blitzTUIRestarts=.*/blitzTUIRestarts=${blitzTUIRestarts}/g" /home/admin/raspiblitz.info
sudo init 3 ; sleep 2 ; sudo init 5
fi
else
echo "blitzTUIHeartBeatLine is empty - skipping check"
fi
blitzTUIHeartBeatLine="${latestHeartBeatLine}"
latestHeartBeatLine=$(sudo tail -n 300 /home/pi/blitz-tui.log | grep beat | tail -n 1)
fi
if [ ${#blitzTUIHeartBeatLine} -gt 0 ]; then
#echo "blitzTUIHeartBeatLine(${blitzTUIHeartBeatLine})"
#echo "latestHeartBeatLine(${latestHeartBeatLine})"
if [ "${blitzTUIHeartBeatLine}" == "${latestHeartBeatLine}" ]; then
echo "FAIL - still no new heart beat .. restarting BlitzTUI"
blitzTUIRestarts=$(($blitzTUIRestarts +1))
if [ $(sudo cat /home/admin/raspiblitz.info | grep -c 'blitzTUIRestarts=') -eq 0 ]; then
echo "blitzTUIRestarts=0" >> /home/admin/raspiblitz.info
fi
sudo sed -i "s/^blitzTUIRestarts=.*/blitzTUIRestarts=${blitzTUIRestarts}/g" /home/admin/raspiblitz.info
sudo init 3 ; sleep 2 ; sudo init 5
fi
else
echo "blitzTUIHeartBeatLine is empty - skipping check"
fi
blitzTUIHeartBeatLine="${latestHeartBeatLine}"
fi
###############################