From d217626318174f4651f6642eb224e4e5f595badb Mon Sep 17 00:00:00 2001 From: Promofaux Date: Wed, 24 Aug 2016 22:52:11 +0100 Subject: [PATCH] If an existing install is detected, offer the user a choice of Updating or Installing with a radio list whiptail. --- automated install/basic-install.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 05170fdf..4e2df395 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -929,10 +929,26 @@ View the web interface at http://pi.hole/admin or http://${IPv4addr%/*}/admin" $ updateDialogs(){ - if (whiptail --title "Existing Install detected" --yesno "We have detected you are installing over the top of an existing install.\n\nIf you would like to update, select yes.\n\n If you would like to run the complete setup again, select no." ${r} ${c}); then - echo "::: Updating existing install selected" - useUpdateVars=true - fi + UpdateCmd=(whiptail --separate-output --radiolist "We have detected an existing install.\n\n Selecting Update will retain settings from the existing install.\n\n Selecting Install will allow you to enter new settings.\n\n(Highlight desired option, and press space to select!)" ${r} ${c} 2) + UpdateChoices=(Update "" on + Install "" off) + UpdateChoice=$("${UpdateCmd[@]}" "${UpdateChoices[@]}" 2>&1 >/dev/tty) + + if [[ $? = 0 ]];then + case ${UpdateChoice} in + Update) + echo "::: Updating existing install" + useUpdateVars=true + ;; + Install) + echo "::: Running complete install script" + useUpdateVars=false + ;; + esac + else + echo "::: Cancel selected. Exiting..." + exit 1 + fi }