handle info wait events

This commit is contained in:
rootzoll 2021-05-06 00:12:09 +02:00
parent 596cc7e7c1
commit a0f90dadbd
2 changed files with 79 additions and 9 deletions

View file

@ -86,15 +86,13 @@ do
if [ "${setupPhase}" != "done" ]; then if [ "${setupPhase}" != "done" ]; then
echo "# DURING SETUP: Handle System States " echo "# DURING SETUP: Handle System State (${state})"
# check if HDD is connected # when no HDD on Vagrant - just print info & exit (admin info)
echo "isMounted(${isMounted}) hddCandidate(${hddCandidate})" if [ "${state}" == "noHDD" ] && [ ${vagrant} -gt 0 ]; then
if [ "${isMounted}" == "0" ] && [ ${#hddCandidate} -eq 0 ]; then echo "***********************************************************"
echo "***********************************************************" echo "VAGRANT INFO"
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart." echo "***********************************************************"
echo "***********************************************************"
if [ ${vagrant} -gt 0 ]; then
echo "To connect a HDD data disk to your VagrantVM:" echo "To connect a HDD data disk to your VagrantVM:"
echo "- shutdown VM with command: off" echo "- shutdown VM with command: off"
echo "- open your VirtualBox GUI and select RaspiBlitzVM" echo "- open your VirtualBox GUI and select RaspiBlitzVM"
@ -106,8 +104,14 @@ do
echo "a VDI with a presynced blockchain to speed up setup. If you dont have 900GB" echo "a VDI with a presynced blockchain to speed up setup. If you dont have 900GB"
echo "space on your laptop you can store the VDI file on an external drive." echo "space on your laptop you can store the VDI file on an external drive."
echo "***********************************************************" echo "***********************************************************"
exit 1
else
# every other state just push as event to SSH frontend
/home/admin/setup.scripts/eventInfoWait.sh ${state}
fi fi
exit 1
fi fi
fi fi

View file

@ -0,0 +1,66 @@
#!/bin/bash
# this is an dialog that handles all UI events during setup that require a "info & wait" with no interaction
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/_version.info
source /home/admin/raspiblitz.info
# 1st PARAMETER: eventID
# fixed ID string for a certain event
eventID=$1
if [ "${eventID}" == "" ]; then
echo "err='missing eventID'"
exit 1
fi
# 2nd PARAMETER (optional): dynamic content that can be used in two ways
# 1) contentWords[] --> if eventID is known & well defined between backend & frontend, then use the single words of this string as dynamic content for static text info
# 2) contentString --> if eventID is new and not well defined yet, then just show a generic info and use the complete string as info message
# just see examples of this two use cases below
contentWords=($2)
contentString=$2
# default backtitle for dialog
backtitle="RaspiBlitz ${codeVersion} / ${locialip} / ${tempCelsius}°C"
################################################
# 1) WELL DEFINED EVENTS
################################################
if [ "${eventID}" == "starting" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Starting RaspiBlitz
Please wait ...
" 6 24
elif [ "${eventID}" == "noHDD" ]; then
# contentWords[1] --> size string (for example '1TB')
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Waiting for HDD/SSD
Please connect min ${contentWords[1]}
HDD or SSD to the the device.
" 8 40
elif [ "${eventID}" == "sdtoosmall" ]; then
# contentWords[1] --> size string (for example '16GB')
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
PROBLEM: SD CARD IS TOO SMALL
Minumum of ${contentWords[1]} needed
Cut power & create fresh sd card
" 8 40
################################################
# 2) GENERIC EVENT
# may get better defined in the future
################################################
else
# a generic info box for not further defined events
dialog --title "${eventid}" --backtitle "${backtitle}" --cr-wrap --infobox "\n${contentString}" 7 50
fi