You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.2 KiB

6 years ago
# load network
network=`sudo cat /home/admin/.network`
# load name of Blitz
name=`sudo cat /home/admin/.hostname`
### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
6 years ago
# parse the actual scanned height progress from LND logs
item=0
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo)
chain="$(echo "${blockchaininfo}" | jq -r '.chain')"
gotData=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c "(height")
6 years ago
if [ ${gotData} -gt 0 ]; then
6 years ago
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')
6 years ago
fi
# get total number of blocks
total=$(echo "${blockchaininfo}" | jq -r '.blocks')
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
6 years ago
# calculate progress in percent
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }")
6 years ago
if [ ${percent} -eq 100 ]; then
6 years ago
# normally if 100% gets calculated, item parsed the wrong height
percent=0
fi
6 years ago
# check if blockchain is still syncing
heigh=6
width=42
isWaitingBlockchain=$(echo "${blockchaininfo}" | grep 'initialblockdownload' | grep "true" -c)
6 years ago
if [ ${isWaitingBlockchain} -gt 0 ]; then
heigh=7
infoStr=" Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A"
if [ "$USER" = "admin" ]; then
heigh=6
width=53
infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some time\n Its OK to close terminal and ssh back in later.")
fi
else
infoStr=$(echo " Lightning Rescanning Blockchain ${percent}%\n Please wait - this can take some time\n ssh admin@${localip}\n Password A")
if [ "$USER" = "admin" ]; then
heigh=5
width=53
infoStr=$(echo " Lightning Rescanning Blockchain ${percent}%\n Please wait - this can take some time\n Its OK to close terminal and ssh back in later.")
fi
6 years ago
fi
6 years ago
# display progress to user
sleep 3
dialog --title " ${network} / ${chain} " --backtitle "RaspiBlitz (${name})" --infobox "${infoStr}" ${heigh} ${width}