raspiblitz/home.admin/setup.scripts/eventInfoWait.sh

201 lines
5.7 KiB
Bash
Raw Normal View History

2021-05-06 00:12:09 +02:00
#!/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
2021-05-19 12:51:17 -05:00
# 3rd PARAMETER (optional): Place of display - could be "lcd" or "ssh" (defalt)
2021-05-19 19:53:57 -05:00
mode=$3
if [ "${mode}" == "" ]; then
mode="ssh"
2021-05-19 12:51:17 -05:00
fi
2021-05-19 19:53:57 -05:00
if [ "${mode}" != "lcd" ] && [ "${mode}" != "ssh" ]; then
2021-05-19 12:51:17 -05:00
echo "error='unknown 3rd parameter value'"
exit 1
fi
2021-05-06 00:12:09 +02:00
# default backtitle for dialog
2021-05-18 21:12:02 -05:00
backtitle="RaspiBlitz ${codeVersion} / ${localip} / ${eventID}"
2021-05-06 00:12:09 +02:00
################################################
# 1) WELL DEFINED EVENTS
################################################
2021-05-06 02:27:26 +02:00
if [ "${eventID}" == "starting" ] || [ "${eventID}" == "system-init" ]; then
2021-05-06 00:12:09 +02:00
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Starting RaspiBlitz
Please wait ...
" 6 24
2021-05-06 02:23:02 +02:00
elif [ "${eventID}" == "reboot" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Shutting down for reboot.
" 5 30
2021-05-21 11:52:20 -05:00
elif [ "${eventID}" == "provision" ] || [ "${eventID}" == "recovering" ]; then
2021-05-19 19:38:34 -05:00
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Upgrade/Recover/Provision
---> ${contentString}
Please keep running until reboot.
2021-05-21 11:52:20 -05:00
" 7 40
2021-05-19 19:38:34 -05:00
elif [ "${eventID}" == "repair" ] && [ "${mode}" == "lcd" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Repair-Mode - Login for Details:
ssh admin@${localip}
Use your Password A
" 7 41
elif [ "${eventID}" == "waitsetup" ] && [ "${mode}" == "lcd" ]; then
2021-05-21 11:52:20 -05:00
if [ "${setupPhase}" == "setup"] || [ "${setupPhase}" == "update" ] || [ "${setupPhase}" == "recovery" ] || [ "${setupPhase}" == "migration" ]; then
# custom backtitle for this dialog
backtitle="RaspiBlitz ${codeVersion} / ${setupPhase}"
# display if HDD conatains blockhain or not
if [ "${hddBlocksBitcoin}" == "1" ] || [ "${hddBlocksLitecoin}" == "1" ]; then
backtitle="${backtitle} / (pre-synced)"
fi
2021-05-19 19:38:34 -05:00
# show default login help info
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Login to your RaspiBlitz with:
ssh admin@${localip}
Use password: raspiblitz
" 7 41
else
# on all other cases (add info message)
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Login for Maintenance:
---> ${contentString}
ssh admin@${localip}
Use password: raspiblitz
" 8 41
fi
2021-05-19 12:51:17 -05:00
elif [ "${eventID}" == "shutdown" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Shutting down - please wait.
" 5 35
2021-05-13 14:31:15 +02:00
elif [ "${eventID}" == "noDHCP" ]; then
2021-05-06 02:27:26 +02:00
2021-05-13 14:31:15 +02:00
# this event is mostly for LCD/HDMI display
# because if device gets no local IP
# SSH & WEBUI would not have connected yet
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Waiting for local IP address ...
If this takes too long please check
your connection to internet router.
" 7 41
2021-05-19 19:53:57 -05:00
elif [ "${eventID}" == "waitsetup" ] && [ "${mode}" == "ssh" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Please wait ...
2021-05-21 21:22:16 -05:00
" 5 24
2021-05-19 19:53:57 -05:00
2021-05-20 21:37:52 -05:00
elif [ "${eventID}" == "waitprovision" ]; then
2021-05-20 21:36:23 -05:00
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Preparing Provision
Please wait ...
" 6 24
2021-05-13 14:31:15 +02:00
elif [ "${eventID}" = "noIP-LAN" ] || [ "${eventID}" = "noIP-WIFI" ]; then
# this event is mostly for LCD/HDMI display
# because if device gets no local IP
# SSH & WEBUI would not have connected yet
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Waiting for Network ...
Not able to get local IP.
LAN cable connected? WIFI lost?
" 7 41
elif [ "${eventID}" = "noInternet" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Waiting for Internet ...
Local Network seems OK but no Internet.
Is your router still online?
" 7 43
elif [ "${eventID}" = "noInternet" ]; then
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
Waiting for Internet ...
Local Network seems OK but no Internet.
Is your router still online?
" 7 43
elif [ "${eventID}" == "inspect-hdd" ]; then
2021-05-06 00:12:09 +02:00
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
2021-05-13 14:31:15 +02:00
Checking HDD/SSD ...
Please wait.
" 6 26
2021-05-06 00:12:09 +02:00
2021-05-18 21:06:32 -05:00
elif [ "${eventID}" == "noHDD" ]; then
2021-05-19 12:51:17 -05:00
# contentWords[0] --> size string (for example '1TB')
2021-05-18 21:06:32 -05:00
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
2021-05-18 21:15:48 -05:00
Waiting for HDD/SSD ...
Please connect a ${contentWords[0]}
HDD or SSD to the device.
2021-05-18 21:16:34 -05:00
" 7 35
2021-05-18 21:06:32 -05:00
2021-05-19 12:51:17 -05:00
elif [ "${eventID}" == "erroHDD" ]; then
# contentString --> detail error message
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
PROBLEM: FAILED HDD/SSD
Detailed Error Message:
${contentString}
" 7 35
2021-05-06 00:12:09 +02:00
elif [ "${eventID}" == "sdtoosmall" ]; then
2021-05-19 12:51:17 -05:00
# contentWords[0] --> size string (for example '16GB')
2021-05-06 00:12:09 +02:00
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
PROBLEM: SD CARD IS TOO SMALL
2021-05-18 21:16:34 -05:00
Minimum of ${contentWords[0]} needed
2021-05-06 00:12:09 +02:00
Cut power & create fresh sd card
2021-05-18 21:16:34 -05:00
" 7 40
2021-05-06 00:12:09 +02:00
################################################
# 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