2018-07-29 01:33:54 +02:00
|
|
|
# load network
|
|
|
|
network=`sudo cat /home/admin/.network`
|
|
|
|
|
2018-08-02 03:50:31 +02:00
|
|
|
### USER PI AUTOSTART (LCD Display)
|
|
|
|
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
|
|
|
|
2018-07-17 13:12:03 +02:00
|
|
|
# parse the actual scanned height progress from LND logs
|
|
|
|
item=0
|
2018-07-29 21:43:16 +02:00
|
|
|
chain="$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
|
2018-08-22 19:25:07 +02:00
|
|
|
gotData=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c "(height")
|
2018-07-17 13:12:03 +02:00
|
|
|
if [ ${gotData} -gt 0 ]; then
|
2018-08-22 21:01:16 +02:00
|
|
|
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "(height" | tail -n1 | awk '{print $10} {print $11} {print $12}' | tr -dc '0-9')
|
2018-07-17 13:12:03 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# get total number of blocks
|
2018-07-29 21:43:16 +02:00
|
|
|
total=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.blocks')
|
2018-07-17 13:12:03 +02:00
|
|
|
|
|
|
|
# calculate progress in percent
|
|
|
|
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }")
|
2018-08-02 18:45:09 +02:00
|
|
|
if [ ${percent} -eq 100 ]; then
|
2018-07-17 13:12:03 +02:00
|
|
|
# normally if 100% gets calculated, item parsed the wrong height
|
|
|
|
percent=0
|
|
|
|
fi
|
|
|
|
|
2018-08-02 18:45:09 +02:00
|
|
|
infoStr=$(echo " Lightning Rescanning Blockchain ${percent}%\nplease wait - this can take some time")
|
|
|
|
|
|
|
|
# check if blockchain is still syncing
|
|
|
|
isWaitingBlockchain=$( sudo -u bitcoin tail -n 2 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Waiting for chain backend to finish sync" -c )
|
|
|
|
if [ ${isWaitingBlockchain} -gt 0 ]; then
|
|
|
|
infoStr=" Waiting for final Blockchain Sync\nplease wait - this can take some time"
|
|
|
|
fi
|
|
|
|
|
2018-07-17 13:12:03 +02:00
|
|
|
# display progress to user
|
2018-08-09 14:44:45 +02:00
|
|
|
sleep 1
|
2018-08-02 18:45:09 +02:00
|
|
|
dialog --backtitle "RaspiBlitz (${localip} / ${network} / ${chain})" --infobox "${infoStr}" 4 42
|