#2649 stop bitcoind & delete small chainm data

This commit is contained in:
rootzoll
2021-11-30 20:08:10 +01:00
parent 3a4aae8ed7
commit 217c1766d2
2 changed files with 41 additions and 23 deletions

View File

@@ -341,6 +341,10 @@ if [ "${lightning}" == "lnd" ]; then
exit 15 exit 15
fi fi
# stop lnd for the rest of the provision process
echo "stopping lnd for the rest provision again (will start on next boot)" >> ${logFile}
systemctl stop lnd >> ${logFile}
fi fi
if [ "${lightning}" == "cl" ]; then if [ "${lightning}" == "cl" ]; then
@@ -413,8 +417,16 @@ if [ "${lightning}" == "cl" ]; then
fi fi
# stop c-lightning for the rest of the provision process
echo "stopping lightningd for the rest provision again (will start on next boot)" >> ${logFile}
systemctl stop lightningd >> ${logFile}
fi fi
# stop bitcoind for the rest of the provision process
echo "stopping bitcoind for the rest provision again (will start on next boot)" >> ${logFile}
systemctl stop bitcoind >> ${logFile}
sudo sed -i "s/^message=.*/message='Provision Setup Finish'/g" ${infoFile} sudo sed -i "s/^message=.*/message='Provision Setup Finish'/g" ${infoFile}
echo "END Setup" >> ${logFile} echo "END Setup" >> ${logFile}
exit 0 exit 0

View File

@@ -81,29 +81,34 @@ if [ "$1" = "target" ]; then
sed -i "s/^message=.*/message='Receiving Blockchain over LAN'/g" /home/admin/raspiblitz.info sed -i "s/^message=.*/message='Receiving Blockchain over LAN'/g" /home/admin/raspiblitz.info
echo "stopping services ..." echo "stopping services ..."
sudo systemctl stop lnd 2>/dev/null
sudo systemctl stop lightningd 2>/dev/null
sudo systemctl stop bitcoind 2>/dev/null sudo systemctl stop bitcoind 2>/dev/null
sudo systemctl disable bitcoind 2>/dev/null sudo systemctl disable bitcoind 2>/dev/null
# check if old blockchain data exists # check if old blockchain data exists (1 Block is 1KB)
hasOldBlockchainData=0 deleteOldBlockchain=0
sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]') sizeBlocks=$(sudo du -s /mnt/hdd/bitcoin/blocks 2>/dev/null | tr -dc '[0-9]')
if [ ${#sizeBlocks} -gt 0 ] && [ ${sizeBlocks} -gt 0 ]; then if [ "${sizeBlocks}" == "" ] || [ ${sizeBlocks} -lt 250000 ]; then
hasOldBlockchainData=1 # blockchain block data is below 250MB ... assume just to be deleted and start copy fresh
fi deleteOldBlockchain=1
sizeChainstate=$(sudo du -s /mnt/hdd/bitcoin/chainstate 2>/dev/null | tr -dc '[0-9]') else
if [ ${#sizeChainstate} -gt 0 ] && [ ${sizeChainstate} -gt 0 ]; then # ask if existing blockchain data should be deleted for not before copy start
hasOldBlockchainData=1 dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60
response=$?
clear
echo "response(${response})"
if [ "${response}" = "1" ]; then
echo "OK - keep old blockchain - just try to repair by copying over it"
sleep 3
else
echo "OK - mark old blockchain to be deleted"
deleteOldBlockchain=1
fi
fi fi
dialog --title " Old Blockchain Data Found " --yesno "\nDo you want to delete the existing blockchain data now?" 7 60 # delete ald blockchain data
response=$? if [ "${deleteOldBlockchain}" == "1" ]; then
clear
echo "response(${response})"
if [ "${response}" = "1" ]; then
echo "OK - keep old blockchain - just try to repair by copying over it"
sleep 3
else
echo "OK - delete old blockchain"
sudo rm -rfv /mnt/hdd/bitcoin/blocks/* 2>/dev/null sudo rm -rfv /mnt/hdd/bitcoin/blocks/* 2>/dev/null
sudo rm -rfv /mnt/hdd/bitcoin/chainstate/* 2>/dev/null sudo rm -rfv /mnt/hdd/bitcoin/chainstate/* 2>/dev/null
sleep 3 sleep 3
@@ -279,6 +284,8 @@ if [ "$1" = "target" ]; then
echo "restarting services ... (please wait)" echo "restarting services ... (please wait)"
sudo systemctl enable bitcoind sudo systemctl enable bitcoind
sudo systemctl start bitcoind sudo systemctl start bitcoind
sudo systemctl start lnd 2>/dev/null
sudo systemctl start lightningd 2>/dev/null
sleep 10 sleep 10
# setting copy state # setting copy state
@@ -327,13 +334,12 @@ if [ "$1" = "source" ]; then
fi fi
echo "# stopping services ..." echo "# stopping services ..."
sudo systemctl stop background sudo systemctl stop lnd 2>/dev/null
sudo systemctl stop lnd sudo systemctl stop lightningd 2>/dev/null
sudo systemctl stop ${network}d sudo systemctl stop ${network}d
sudo systemctl disable ${network}d sudo systemctl disable ${network}d
sleep 5 sleep 5
sudo systemctl stop bitcoind 2>/dev/null
clear clear
echo echo
echo "# Starting copy over LAN (around 4-6 hours) ..." echo "# Starting copy over LAN (around 4-6 hours) ..."
@@ -390,8 +396,8 @@ if [ "$1" = "source" ]; then
echo "# start services again ..." echo "# start services again ..."
sudo systemctl enable ${network}d sudo systemctl enable ${network}d
sudo systemctl start ${network}d sudo systemctl start ${network}d
sudo systemctl start lnd sudo systemctl start lnd 2>/dev/null
sudo systemctl start background sudo systemctl start lightningd 2>/dev/null
echo "# show final message" echo "# show final message"
whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain" whiptail --msgbox "OK - Copy Process Finished.\n\nNow check on the target RaspiBlitz if it was sucessful." 10 40 "" --title " DONE " --backtitle "RaspiBlitz - Copy Blockchain"