From 4609f908601bf0076cd55b8351755672a7dc6512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 25 Feb 2025 14:24:59 +0100 Subject: [PATCH] Show an warning dialoge before performing an update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/update.sh | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 9ea63b4c..07db152e 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -97,6 +97,50 @@ GitCheckUpdateAvail() { fi } +updateWarnDialog() { + # Display the warning dialog + + local core_str web_str ftl_str + + if [[ "${core_update}" == true ]]; then + core_str="Core: \\Zb\\Z1update available\\Zn" + else + core_str="Core: \\Zb\\Z4up to date\\Zn" + fi + if [[ "${web_update}" == true ]]; then + web_str="Web Interface: \\Zb\\Z1update available\\Zn" + else + web_str="Web Interface: \\Zb\\Z4up to date\\Zn" + fi + if [[ "${FTL_update}" == true ]]; then + ftl_str="FTL: \\Zb\\Z1update available\\Zn" + else + ftl_str="FTL: \\Zb\\Z4up to date\\Zn" + fi + # shellcheck disable=SC2154 # Variables "${r}" "${c}" are defined in the main script + dialog --no-shadow --clear --keep-tite \ + --colors \ + --backtitle "Updating Pi-hole" \ + --title "Warning" \ + --no-button "Exit" --yes-button "Continue" \ + --defaultno \ + --yesno "\\nThe following Pi-hole components are going to be updated.\\n\\n\\n\ + $core_str\\n\ + $web_str\\n\ + $ftl_str\\n\\n\\n\ +\\Zb\\Z1IMPORTANT:\\Zn Make a (teleporter) backup of your system!\\n\\n\ +Updates can come with significant changes. Please read the changelog carefully.\\n\\n\\n\ +Please confirm you want to start the update process." \ + "${r}" "${c}" && result=0 || result="$?" + + case "${result}" in + "${DIALOG_CANCEL}" | "${DIALOG_ESC}") + printf " %b User canceled the update process.\\n" "${INFO}" + exit 1 + ;; + esac +} + main() { local basicError="\\n ${COL_LIGHT_RED}Unable to complete update, please contact Pi-hole Support${COL_NC}" local core_update @@ -198,6 +242,11 @@ main() { exit 0 fi + # if there is any update, show the warning dialog and ask for confirmation + if [[ "${core_update}" == true || "${web_update}" == true || "${FTL_update}" == true ]]; then + updateWarnDialog + fi + if [[ "${core_update}" == true ]]; then echo "" echo -e " ${INFO} Pi-hole core files out of date, updating local repo."