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
|
2021-08-19 00:18:59 +02:00
|
|
|
pause=3
|
2019-10-06 12:37:35 +02:00
|
|
|
|
2021-08-13 10:30:57 +02:00
|
|
|
# this is used by touchscreen and command 'status'
|
2021-05-20 02:38:34 +02:00
|
|
|
# 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}
|
|
|
|
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
|
|
|
|
if [ ${configExists} -eq 1 ]; then
|
|
|
|
source ${configFile}
|
2021-05-28 21:52:10 +02:00
|
|
|
source <(/home/admin/config.scripts/network.aliases.sh getvars)
|
2019-12-11 13:47:21 +01:00
|
|
|
fi
|
|
|
|
|
2021-06-21 02:33:28 +02:00
|
|
|
if [ "${setupPhase}" != "done" ] || [ "${state}" == "copytarget" ] || [ "${state}" == "copysource" ] || [ "${state}" == "copystation" ]; then
|
2019-12-11 13:59:33 +01:00
|
|
|
|
2021-05-20 02:38:34 +02:00
|
|
|
# show status info during boot & setup & repair on LCD
|
|
|
|
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}" lcd
|
2019-12-11 13:47:21 +01:00
|
|
|
sleep 1
|
2018-12-10 21:29:22 +01:00
|
|
|
continue
|
2018-12-12 16:12:30 +01:00
|
|
|
|
2019-05-18 21:25:46 +02:00
|
|
|
fi
|
|
|
|
|
2021-08-13 10:30:57 +02:00
|
|
|
# TODO: ALSO SEPARATE GUI/ACTION FOR THE SCANNING / WALLET UNLOCK / ERROR DETECTION
|
2021-07-25 00:55:02 +02:00
|
|
|
# if lightning is syncing or scanning
|
2021-08-13 10:30:57 +02:00
|
|
|
source <(sudo /home/admin/config.scripts/blitz.statusscan.sh $lightning)
|
2021-08-26 17:22:41 +02:00
|
|
|
if [ "${walletLocked}" == "1" ]; then
|
|
|
|
/home/admin/setup.scripts/eventInfoWait.sh "walletlocked" "" lcd
|
|
|
|
sleep 3
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2021-07-25 00:55:02 +02:00
|
|
|
if [ "${syncedToChain}" != "1" ]; then
|
2021-07-03 23:54:22 +02:00
|
|
|
/home/admin/setup.scripts/eventBlockchainSync.sh lcd
|
|
|
|
sleep 10
|
2018-12-10 21:29:22 +01:00
|
|
|
continue
|
2018-11-04 04:05:25 +01:00
|
|
|
fi
|
|
|
|
|
2018-12-10 21:29:22 +01:00
|
|
|
# no special case - show status display
|
2021-08-13 10:30:57 +02:00
|
|
|
/home/admin/00infoBlitz.sh $lightning ${chain}net
|
2019-12-28 15:25:38 +01:00
|
|
|
sleep 5
|
2018-07-17 13:12:03 +02:00
|
|
|
|
2019-12-28 15:25:38 +01:00
|
|
|
done
|