raspiblitz/home.admin/80scanLND.sh

267 lines
9.2 KiB
Bash
Raw Normal View History

2019-02-02 23:49:04 +01:00
#!/bin/bash
2019-04-16 22:00:49 +01:00
source /home/admin/_version.info
2019-02-02 23:49:04 +01:00
source /home/admin/raspiblitz.info
2019-02-05 18:24:33 +01:00
source /mnt/hdd/raspiblitz.conf
2018-08-24 00:11:33 +02:00
2019-04-23 16:22:29 +02:00
# all system/service info gets detected by blitz.statusscan.sh
2019-04-16 21:48:22 +01:00
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh)
2019-04-25 14:48:26 +02:00
# when admin and no other error found run LND setup check
if [ "$USER" == "admin" ] && [ ${#lndErrorFull} -eq 0 ]; then
lndErrorFull=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err=" | tail -1)
fi
2019-04-23 16:22:29 +02:00
# set follow up info different for LCD and ADMIN
2019-04-16 22:07:59 +01:00
adminStr="ssh admin@${localIP} ->Password A"
if [ "$USER" == "admin" ]; then
adminStr="Use CTRL+c to EXIT to Terminal"
fi
2018-08-02 18:45:09 +02:00
2019-04-23 16:22:29 +02:00
# bitcoin errors always first
2019-04-25 01:55:11 +02:00
if [ ${bitcoinActive} -eq 0 ] || [ ${#bitcoinErrorFull} -gt 0 ] || [ "${1}" == "blockchain-error" ]; then
2019-04-16 22:23:06 +01:00
2020-03-29 22:26:11 +02:00
####################
# Copy Blockchain Source Mode
# https://github.com/rootzoll/raspiblitz/issues/1081
####################
if [ "${state}" = "copysource" ]; then
l1="Copy Blockchain Source Modus\n"
2020-06-17 23:09:47 +02:00
l2="May needs restart node when done.\n"
l3="Restart from Terminal: restart"
dialog --backtitle "RaspiBlitz ${codeVersion} (${state}) ${localIP}" --infobox "$l1$l2$l3" 5 45
2020-03-29 22:26:11 +02:00
sleep 3
exit 1
fi
2019-04-16 22:23:06 +01:00
####################
# On Bitcoin Error
####################
2020-02-19 19:05:13 +01:00
height=6
2019-04-17 00:30:39 +01:00
width=43
2019-04-16 23:16:49 +01:00
title="Blockchain Info"
2020-06-28 16:23:34 +02:00
if [ ${#bitcoinErrorShort} -eq 0 ]; then
bitcoinErrorShort="Initial Startup - Please Wait"
fi
if [ "$USER" != "admin" ]; then
if [ ${uptime} -gt 600 ] || ${#bitcoinErrorFull} -gt 0 ] || [ "${1}" == "blockchain-error" ]; then
2020-06-28 19:29:32 +02:00
infoStr=" The ${network}d service is NOT RUNNING!\n\n Login for more details & options:"
2020-06-28 16:23:34 +02:00
else
infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Login with SSH for more details:"
fi
else
2020-06-28 16:31:05 +02:00
# output when user login in as admin and bitcoind is not running
2020-06-28 16:35:36 +02:00
if [ ${uptime} -gt 600 ] || ${#bitcoinErrorFull} -gt 0 ] || [ "${bitcoinErrorShort}" == "Error found in Logs" ] || [ "${1}" == "blockchain-error" ]; then
2020-06-28 16:23:34 +02:00
2019-04-24 16:59:28 +02:00
clear
2019-04-16 23:34:53 +01:00
echo ""
echo "*****************************************"
echo "* The ${network}d service is not running."
echo "*****************************************"
echo "If you just started some config/setup, this might be OK."
2019-04-16 23:09:38 +01:00
echo
2019-04-24 13:47:58 +02:00
if [ ${startcountBlockchain} -gt 1 ]; then
echo "${startcountBlockchain} RESTARTS DETECTED - ${network}d might be in a error loop"
2019-04-25 02:51:01 +02:00
cat /home/admin/systemd.blockchain.log | grep "ERROR" | tail -n -1
2019-04-24 13:47:58 +02:00
echo
fi
2019-04-17 00:03:36 +01:00
if [ ${#bitcoinErrorFull} -gt 0 ]; then
2019-04-16 23:34:53 +01:00
echo "More Error Detail:"
2019-04-17 00:03:36 +01:00
echo ${bitcoinErrorFull}
2019-04-16 23:34:53 +01:00
echo
fi
# check if maybe problems with txindex
source <(/home/admin/config.scripts/network.txindex.sh status)
if [ "${txindex}" == "1" ]; then
if [ "${indexFinished}" == "0" ]; then
# bitcoind is not starting while still building index - recommend turning off index and restart
whiptail --title "Problems with Bitcoin Index" --yes-button "TurnOff TxIndex" --no-button "Do Nothing" --yesno "It looks like ${network}d has problems building the txindex. Turning Off the txindex and restart is recommended." 10 60
if [ $? -eq 0 ]; then
# delete txindex, turn off and deactivate apps needed index
sudo /home/admin/config.scripts/network.txindex.sh delete
whiptail --msgbox "OK txindex was turned off.\n\nTo be able to build a valid txindex in the future you might need to reset/redownload the blockchain." 10 56 "" --title " TXINDEX OFF "
/home/admin/XXshutdown.sh reboot
fi
else
# bitcoind is not starting but index was build in the past - recommend repair with turning off index
echo "-> Use command 'repair' and then choose 'DELETE-INDEX' to try rebuilding transaction index."
fi
fi
echo "-> Use command 'repair' and then choose 'RESET-CHAIN' to try downloading new blockchain."
echo "-> Use command 'debug' for more log output you can use for getting support."
echo "-> Use command 'menu' to open main menu."
echo "-> Have you tried to turn it off and on again? Use command 'restart'"
2019-04-16 23:34:53 +01:00
echo ""
2020-06-28 16:23:34 +02:00
echo "Use CTRL+c to EXIT to Terminal"
sleep 10
exit 1
2020-06-28 16:23:34 +02:00
else
infoStr=" The ${network}d service is starting:\n ${bitcoinErrorShort}\n Please wait up to 10min ..."
2019-04-16 23:34:53 +01:00
fi
2020-06-28 16:23:34 +02:00
fi
2019-04-23 16:22:29 +02:00
# LND errors second
2019-04-25 01:55:11 +02:00
elif [ ${lndActive} -eq 0 ] || [ ${#lndErrorFull} -gt 0 ] || [ "${1}" == "lightning-error" ]; then
2019-04-16 22:23:06 +01:00
####################
# On LND Error
####################
2020-02-19 19:05:13 +01:00
height=6
2019-04-17 00:30:39 +01:00
width=43
2019-04-16 23:16:49 +01:00
title="Lightning Info"
2019-04-25 01:55:11 +02:00
if [ ${uptime} -gt 600 ] || [ "${1}" == "lightning-error" ]; then
2019-04-26 15:12:20 +02:00
if [ ${#lndErrorShort} -gt 0 ]; then
2019-04-26 15:14:35 +02:00
height=6
2019-04-26 15:12:20 +02:00
lndErrorShort=" ${lndErrorShort}\n"
fi
if [ ${lndActive} -eq 0 ]; then
infoStr=" The LND service is not running.\n${lndErrorShort} Login for more details:"
else
infoStr=" The LND service is running with error.\n${lndErrorShort} Login for more details:"
fi
2019-04-16 23:34:53 +01:00
if [ "$USER" == "admin" ]; then
2019-04-24 16:59:28 +02:00
clear
2019-04-16 23:34:53 +01:00
echo ""
2019-04-26 15:12:20 +02:00
echo "****************************************"
if [ ${lndActive} -eq 0 ]; then
echo "* The LND service is not running."
else
echo "* The LND service is running with error."
fi
echo "****************************************"
2019-04-16 23:34:53 +01:00
echo "If you just started some config/setup, this might be OK."
2019-04-16 23:09:38 +01:00
echo
2019-04-24 13:47:58 +02:00
if [ ${startcountLightning} -gt 1 ]; then
2019-04-25 04:10:13 +02:00
echo "${startcountLightning} RESTARTS DETECTED - LND might be in a error loop"
2019-04-25 02:51:01 +02:00
cat /home/admin/systemd.lightning.log | grep "ERROR" | tail -n -1
2019-04-24 13:47:58 +02:00
fi
2019-04-25 04:10:13 +02:00
sudo journalctl -u lnd -b --no-pager -n14 | grep "lnd\["
2019-04-25 14:48:26 +02:00
sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err="
2019-04-17 00:03:36 +01:00
if [ ${#lndErrorFull} -gt 0 ]; then
2019-04-16 23:34:53 +01:00
echo "More Error Detail:"
2019-04-17 00:03:36 +01:00
echo ${lndErrorFull}
2019-04-16 23:34:53 +01:00
fi
2019-04-25 04:12:12 +02:00
echo
2020-06-29 21:54:29 +02:00
echo "-> Use command 'repair' and then choose 'BACKUP-LND' to make a just in case backup."
2020-06-29 21:51:55 +02:00
echo "-> Use command 'debug' for more log output you can use for getting support."
echo "-> Use command 'menu' to open main menu."
echo "-> Have you tried to turn it off and on again? Use command 'restart'"
2019-04-16 23:34:53 +01:00
echo ""
exit 1
2019-04-25 15:54:49 +02:00
else
2019-04-25 16:02:14 +02:00
source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
if [ ${wallet} -eq 0 ] || [ ${macaroon} -eq 0 ] || [ ${config} -eq 0 ] || [ ${tls} -eq 0 ]; then
infoStr=" The LND service needs RE-SETUP.\n Login with SSH to continue:"
fi
fi
2019-04-16 23:34:53 +01:00
else
infoStr=" The LND service is starting.\n Login for more details:"
if [ "$USER" == "admin" ]; then
infoStr=" The LND service is starting.\n Please wait up to 5min ..."
2019-04-16 23:09:38 +01:00
fi
2019-04-16 22:23:06 +01:00
fi
2019-04-23 16:22:29 +02:00
# if LND wallet is locked
2019-04-25 00:03:49 +02:00
elif [ ${walletLocked} -gt 0 ]; then
2019-04-25 00:07:48 +02:00
height=5
width=43
2019-04-23 16:22:29 +02:00
if [ "${autoUnlock}" = "on" ]; then
2019-04-25 00:07:48 +02:00
title="Auto Unlock"
2019-04-23 16:22:29 +02:00
infoStr=" Waiting for Wallet Auto-Unlock.\n Please wait up to 5min ..."
else
2019-04-25 00:07:48 +02:00
title="Action Required"
2019-04-25 01:29:49 +02:00
infoStr=" LND WALLET IS LOCKED !!!\n"
2019-04-23 16:22:29 +02:00
if [ "${rtlWebinterface}" = "on" ]; then
height=6
infoStr="${infoStr} Browser: http://${localIP}:3000\n PasswordB=login / PasswordC=unlock"
else
infoStr="${infoStr} Please use SSH to unlock:"
2019-04-25 01:21:29 +02:00
fi
2019-04-25 01:03:03 +02:00
if [ ${startcountLightning} -gt 1 ]; then
2019-04-25 01:30:48 +02:00
width=45
2019-04-25 03:34:54 +02:00
height=$((height+3))
2019-04-25 01:29:49 +02:00
infoStr=" LIGHTNING RESTARTED - login for details\n${infoStr}"
2019-04-25 03:34:54 +02:00
adminStr="${adminStr}\n or choose 'INFO' in main menu\n or type 'raspiblitz' on terminal"
2019-04-25 01:03:03 +02:00
fi
2019-04-23 16:22:29 +02:00
fi
2019-04-16 22:23:06 +01:00
else
####################
# Sync Progress
####################
# basic dialog info
height=6
2019-04-17 00:30:39 +01:00
width=43
2019-04-16 22:24:01 +01:00
title="Node is Syncing (${scriptRuntime})"
2019-04-24 16:23:15 +02:00
actionString="Please wait - this can take some time"
2019-04-16 22:23:06 +01:00
2019-04-26 21:38:54 +02:00
# formatting BLOCKCHAIN SYNC PROGRESS
2019-04-16 23:15:41 +01:00
if [ ${#syncProgress} -eq 0 ]; then
2019-04-25 01:03:03 +02:00
if [ ${startcountBlockchain} -lt 2 ]; then
2019-04-24 16:23:15 +02:00
syncProgress="waiting"
else
syncProgress="${startcountBlockchain} restarts"
2019-04-24 16:42:16 +02:00
actionString="Login with SSH for more details:"
2019-04-24 16:23:15 +02:00
fi
2019-04-16 23:15:41 +01:00
elif [ ${#syncProgress} -lt 6 ]; then
syncProgress=" ${syncProgress} %"
else
syncProgress="${syncProgress} %"
2019-04-16 22:23:06 +01:00
fi
2019-04-26 21:38:54 +02:00
# formatting LIGHTNING SCAN PROGRESS
2019-04-16 23:15:41 +01:00
if [ ${#scanProgress} -eq 0 ]; then
2019-04-25 14:48:26 +02:00
2019-04-26 21:38:54 +02:00
# in case of LND RPC is not ready yet
if [ ${scanTimestamp} -eq -2 ]; then
2019-04-27 01:10:11 +02:00
scanProgress="prepare sync"
2019-04-26 21:38:54 +02:00
# in case LND restarting >2
elif [ ${startcountLightning} -gt 2 ]; then
scanProgress="${startcountLightning} restarts"
actionString="Login with SSH for more details:"
2019-04-25 14:48:26 +02:00
2019-04-26 21:38:54 +02:00
# check if a specific error can be identified for restarts
2019-04-25 14:48:26 +02:00
lndSetupErrorCount=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep -c "err=")
if [ ${lndSetupErrorCount} -gt 0 ]; then
scanProgress="possible error"
fi
2019-04-26 21:38:54 +02:00
# unkown cases
2019-04-24 16:23:15 +02:00
else
2019-04-26 21:38:54 +02:00
scanProgress="waiting"
2019-04-24 16:23:15 +02:00
fi
2019-04-26 21:38:54 +02:00
2019-04-16 23:15:41 +01:00
elif [ ${#scanProgress} -lt 6 ]; then
scanProgress=" ${scanProgress} %"
else
scanProgress="${scanProgress} %"
2019-04-16 22:23:06 +01:00
fi
2019-04-16 23:15:41 +01:00
# setting info string
2019-04-24 16:23:15 +02:00
infoStr=" Blockchain Progress : ${syncProgress}\n Lightning Progress : ${scanProgress}\n ${actionString}"
2019-04-16 22:23:06 +01:00
fi
# display info to user
2019-04-16 22:08:55 +01:00
dialog --title " ${title} " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width}