arno
2020-07-19 23:45:23 +02:00
committed by GitHub
parent aa486e3f05
commit a2a2d91eeb
2 changed files with 12 additions and 10 deletions

View File

@@ -285,7 +285,7 @@ case $CHOICE in
;; ;;
REBOOT) REBOOT)
clear clear
confirmation "Reboot" true 9 40 confirmation "Are you sure?" "Reboot" "Cancel" true 7 40
confirmationReboot=$? confirmationReboot=$?
if [ $confirmationReboot -eq 0 ]; then if [ $confirmationReboot -eq 0 ]; then
clear clear
@@ -296,7 +296,7 @@ case $CHOICE in
;; ;;
OFF) OFF)
clear clear
confirmation "PowerOff" true 9 40 confirmation "Are you sure?" "PowerOff" "Cancel" true 7 40
confirmationShutdown=$? confirmationShutdown=$?
if [ $confirmationShutdown -eq 0 ]; then if [ $confirmationShutdown -eq 0 ]; then
clear clear

View File

@@ -3,20 +3,22 @@
confirmation() confirmation()
{ {
local text=$1 local text=$1
local defaultno=$2 local yesButtonText=$2
local height=$3 local noButtonText=$3
local width=$4 local defaultno=$4
local height=$5
local width=$6
local answer=-100
if [ $defaultno ]; then if [ $defaultno ]; then
whiptail --title " Confirmation " --defaultno --yes-button "Yes" --no-button "No" --yesno " $1 whiptail --title " Confirmation " --defaultno --yes-button "$yesButtonText" --no-button "$noButtonText" --yesno " $text
Are you sure?
" $height $width " $height $width
else else
whiptail --title " Confirmation " --yes-button "Yes" --no-button "No" --yesno " $1 whiptail --title " Confirmation " --yes-button "$yesButtonText" --no-button "$noButtonText" --yesno " $text
Are you sure?
" $height $width " $height $width
fi fi
return $? answer=$?
return $answer
} }