confirmation for reboot and shutdown

This commit is contained in:
arno
2020-07-18 12:36:43 +02:00
parent 222d3c24b9
commit 38615cf0a2
2 changed files with 45 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
#!/bin/bash
echo "Starting the main menu ..."
# CONFIGFILE - configuration of RaspiBlitz
@@ -7,9 +8,13 @@ configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# CONFIRMATIONFILE - confirmation dialog
confirmationFile="/home/admin/XXconfirmation.sh"
# MAIN MENU AFTER SETUP
source ${infoFile}
source ${configFile}
source ${confirmationFile}
# get the local network IP to be displayed on the lCD
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0' | grep 'eth0\|wlan0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
@@ -279,16 +284,26 @@ case $CHOICE in
/home/admin/99updateMenu.sh
;;
REBOOT)
clear
echo ""
sudo /home/admin/XXshutdown.sh reboot
exit 0
clear
confirmation "Reboot" true 9 40
confirmationReboot=$?
if [ $confirmationReboot -eq 0 ]; then
clear
echo ""
sudo /home/admin/XXshutdown.sh reboot
exit 0
fi
;;
OFF)
clear
echo ""
sudo /home/admin/XXshutdown.sh
exit 0
clear
confirmation "PowerOff" true 9 40
confirmationShutdown=$?
if [ $confirmationShutdown -eq 0 ]; then
clear
echo ""
sudo /home/admin/XXshutdown.sh
exit 0
fi
;;
DELETE)
sudo /home/admin/XXcleanHDD.sh

22
home.admin/XXconfirmation.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
confirmation()
{
text=$1
defaultno=$2
height=$3
width=$4
if [ $defaultno ]; then
whiptail --title " Confirmation " --defaultno --yes-button "Yes" --no-button "No" --yesno " $1
Are you sure?
" $height $width
else
whiptail --title " Confirmation " --yes-button "Yes" --no-button "No" --yesno " $1
Are you sure?
" $height $width
fi
return $?
}