raspiblitz/home.admin/00infoLCD.sh

113 lines
2.5 KiB
Bash
Raw Normal View History

2018-11-04 04:15:23 +01:00
#!/bin/bash
2018-07-17 13:12:03 +02:00
2018-10-15 22:31:56 +02:00
### USER PI AUTOSTART (LCD Display)
# this script gets started by the autologin of the pi user and
# and its output is gets displayed on the LCD or the RaspiBlitz
2018-08-24 23:29:22 +02:00
2019-10-06 12:37:35 +02:00
function usage() {
echo -e "This script gets started by the autologin of the pi user and "
echo -e "and its output is gets displayed on the LCD or the RaspiBlitz."
echo -e ""
echo -e "Usage: $0 [-h|--help] [-v*|--verbose] [-p|--pause STRING]"
echo -e ""
echo -e " -h, --help\t\tprint this help message"
echo -e " -v, --verbose\t\tbe more verbose"
echo -e " -p, --pause STRING\ttime in seconds to pause"
echo -e ""
}
# Default Values
verbose=0
pause=12
2021-05-19 19:38:34 -05:00
# this is used by touchscreen and command 'satus'
# TODO: remove on v1.8
2019-10-06 12:37:35 +02:00
while [[ "$1" == -* ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-v*)
(( verbose += ${#1} - 1 ))
;;
--verbose)
(( verbose++ ))
;;
-p|--pause)
shift
pause="$1"
;;
--)
shift
break
;;
*)
echo "Unrecognized option $1."
echo ""
usage
exit 1
;;
esac
shift
done
if ! [[ "$pause" =~ ^[[:digit:]]+$ ]]; then
echo "pause must be a positive integer or 0." >&2
exit 1
fi
2018-12-10 21:29:22 +01:00
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
2018-10-15 22:31:56 +02:00
# check that user is pi
if [ "$USER" != "pi" ]; then
echo "plz run as user pi --> su pi"
exit 1
fi
2018-08-24 23:29:22 +02:00
2018-12-10 21:29:22 +01:00
# display a 10s startup time
2018-12-12 19:45:59 +01:00
source /home/admin/_version.info
2019-10-06 12:37:35 +02:00
if [ "$pause" -ne "0" ]; then
dialog --pause " Starting RaspiBlitz v${codeVersion} ..." 8 58 ${pause}
fi
2018-11-04 01:21:58 +01:00
2018-10-15 22:31:56 +02:00
# DISPLAY LOOP
chain=""
while :
do
2018-12-10 21:29:22 +01:00
###########################
# CHECK BASIC DATA
###########################
2019-12-11 14:10:34 +01:00
# get config info if already available (with state value)
2019-12-11 13:47:21 +01:00
source ${infoFile}
2018-10-15 22:31:56 +02:00
2021-05-19 19:38:34 -05:00
if [ "${setupPhase}" != "ready" ]; then
2021-05-04 01:51:22 +02:00
2021-05-19 19:38:34 -05:00
# show status info during boot & setup & repair on LCD
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}" lcd
2021-05-04 01:35:48 +02:00
sleep 1
continue
2019-05-18 21:25:46 +02:00
fi
2021-05-19 19:38:34 -05:00
# TODO: ALSO SEPERATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION
2018-12-10 21:29:22 +01:00
# if LND is syncing or scanning
2018-12-12 14:53:48 +01:00
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
2018-12-10 21:29:22 +01:00
if [ ${lndSynced} -eq 0 ]; then
/home/admin/80scanLND.sh
sleep 20
continue
2018-11-04 04:05:25 +01:00
fi
2018-12-10 21:29:22 +01:00
# no special case - show status display
2019-12-28 14:25:38 +00:00
/home/admin/00infoBlitz.sh
sleep 5
2018-07-17 13:12:03 +02:00
2019-12-28 14:25:38 +00:00
done