From 49cf5bb221240525eea956cfdbd44de5ea5dd25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 6 Feb 2025 21:26:14 +0100 Subject: [PATCH 1/3] Remove 'reconfigure' option 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 | 2 +- advanced/bash-completion/pihole | 2 +- automated install/basic-install.sh | 52 +++++++++++------------------- pihole | 10 +++--- 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 9ea63b4c..6c6167c0 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -218,7 +218,7 @@ main() { fi if [[ "${FTL_update}" == true || "${core_update}" == true ]]; then - ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || \ + ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --repair --unattended || \ echo -e "${basicError}" && exit 1 fi diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole index 4343cf92..cf99ab73 100644 --- a/advanced/bash-completion/pihole +++ b/advanced/bash-completion/pihole @@ -7,7 +7,7 @@ _pihole() { case "${prev}" in "pihole") - opts="allow allow-regex allow-wild deny checkout debug disable enable flush help logging query reconfigure regex reloaddns reloadlists status tail uninstall updateGravity updatePihole version wildcard arpflush api" + opts="allow allow-regex allow-wild deny checkout debug disable enable flush help logging query repair regex reloaddns reloadlists status tail uninstall updateGravity updatePihole version wildcard arpflush api" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) ;; "allow"|"deny"|"wildcard"|"regex"|"allow-regex"|"allow-wild") diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8b21ccf7..744f9d2c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -142,12 +142,12 @@ EOM ######## Undocumented Flags. Shhh ######## # These are undocumented flags; some of which we can use when repairing an installation # The runUnattended flag is one example of this -reconfigure=false +repair=false runUnattended=false # Check arguments for the undocumented flags for var in "$@"; do case "$var" in - "--reconfigure") reconfigure=true ;; + "--repair") repair=true ;; "--unattended") runUnattended=true ;; esac done @@ -1111,7 +1111,7 @@ setPrivacyLevel() { # A function to display a list of example blocklists for users to select chooseBlocklists() { - # Back up any existing adlist file, on the off chance that it exists. Useful in case of a reconfigure. + # Back up any existing adlist file, on the off chance that it exists. if [[ -f "${adlistFile}" ]]; then mv "${adlistFile}" "${adlistFile}.old" fi @@ -1787,21 +1787,12 @@ displayFinalMessage() { \\n${additional}" "${r}" "${c}" } -update_dialogs() { - # If pihole -r "reconfigure" option was selected, - if [[ "${reconfigure}" = true ]]; then - # set some variables that will be used - opt1a="Repair" - opt1b="This will retain existing settings" - strAdd="You will remain on the same version" - else - # Otherwise, set some variables with different values - opt1a="Update" - opt1b="This will retain existing settings." - strAdd="You will be updated to the latest version." - fi - opt2a="Reconfigure" - opt2b="Resets Pi-hole and allows re-selecting settings." +repair_dialog() { + # pihole -r/--repair option was selected + # set some variables that will be used + opt1a="Repair" + opt1b="This will retain existing settings" + strAdd="You will remain on the same version" # Display the information to the user UpdateCmd=$(dialog --no-shadow --keep-tite --output-fd 1 \ @@ -1810,9 +1801,8 @@ update_dialogs() { --menu "\\n\\nWe have detected an existing install.\ \\n\\nPlease choose from the following options:\ \\n($strAdd)" \ - "${r}" "${c}" 2 \ - "${opt1a}" "${opt1b}" \ - "${opt2a}" "${opt2b}") || result=$? + "${r}" "${c}" 1 \ + "${opt1a}" "${opt1b}") || result=$? case ${result} in "${DIALOG_CANCEL}" | "${DIALOG_ESC}") @@ -1823,16 +1813,11 @@ update_dialogs() { # Set the variable based on if the user chooses case ${UpdateCmd} in - # repair, or + # repair "${opt1a}") printf " %b %s option selected\\n" "${INFO}" "${opt1a}" useUpdateVars=true ;; - # reconfigure, - "${opt2a}") - printf " %b %s option selected\\n" "${INFO}" "${opt2a}" - useUpdateVars=false - ;; esac } @@ -1923,9 +1908,9 @@ checkout_pull_branch() { } clone_or_update_repos() { - # If the user wants to reconfigure, - if [[ "${reconfigure}" == true ]]; then - printf " %b Performing reconfiguration, skipping download of local repos\\n" "${INFO}" + # If the user wants to repair/update, + if [[ "${repair}" == true ]]; then + printf " %b Resetting local repos\\n" "${INFO}" # Reset the Core repo resetRepo ${PI_HOLE_LOCAL_REPO} || { @@ -1938,7 +1923,7 @@ clone_or_update_repos() { printf " %b Unable to reset %s, exiting installer%b\\n" "${COL_LIGHT_RED}" "${webInterfaceDir}" "${COL_NC}" exit 1 } - # Otherwise, a repair is happening + # Otherwise, a fresh installation is happening else # so get git files for Core getGitFiles ${PI_HOLE_LOCAL_REPO} ${piholeGitUrl} || @@ -2455,8 +2440,9 @@ main() { # also disable debconf-apt-progress dialogs export DEBIAN_FRONTEND="noninteractive" else - # If running attended, show the available options (repair/reconfigure) - update_dialogs + # If running attended, show the available options (repair/cancel) + # if repair is selected useUpdateVars will be 'true' + repair_dialog fi fi diff --git a/pihole b/pihole index 6424c793..39cb3070 100755 --- a/pihole +++ b/pihole @@ -107,11 +107,11 @@ updatePiholeFunc() { fi } -reconfigurePiholeFunc() { +repairPiholeFunc() { if [ -n "${DOCKER_VERSION}" ]; then unsupportedFunc else - /etc/.pihole/automated\ install/basic-install.sh --reconfigure + /etc/.pihole/automated\ install/basic-install.sh --repair exit 0; fi } @@ -476,7 +476,7 @@ Debugging Options: Add '-c' or '--check-database' to include a Pi-hole database integrity check Add '-a' to automatically upload the log to tricorder.pi-hole.net -f, flush Flush the Pi-hole log - -r, reconfigure Reconfigure or Repair Pi-hole subsystems + -r, repair Repair Pi-hole subsystems -t, tail [arg] View the live output of the Pi-hole log. Add an optional argument to filter the log (regular expressions are supported) @@ -533,7 +533,7 @@ case "${1}" in "--allow-wild" | "allow-wild" ) need_root=0;; "-f" | "flush" ) ;; "-up" | "updatePihole" ) ;; - "-r" | "reconfigure" ) ;; + "-r" | "repair" ) ;; "-l" | "logging" ) ;; "uninstall" ) ;; "enable" ) need_root=0;; @@ -576,7 +576,7 @@ case "${1}" in "-d" | "debug" ) debugFunc "$@";; "-f" | "flush" ) flushFunc "$@";; "-up" | "updatePihole" ) updatePiholeFunc "$@";; - "-r" | "reconfigure" ) reconfigurePiholeFunc;; + "-r" | "repair" ) repairPiholeFunc;; "-g" | "updateGravity" ) updateGravityFunc "$@";; "-l" | "logging" ) piholeLogging "$@";; "uninstall" ) uninstallFunc;; From dfc2b32248bd0d74e68e4879a5f8fa331b77e46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 6 Feb 2025 21:55:08 +0100 Subject: [PATCH 2/3] Use better function name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 744f9d2c..05219357 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1907,7 +1907,7 @@ checkout_pull_branch() { return 0 } -clone_or_update_repos() { +clone_or_reset_repos() { # If the user wants to repair/update, if [[ "${repair}" == true ]]; then printf " %b Resetting local repos\\n" "${INFO}" @@ -2469,8 +2469,8 @@ main() { # Setup adlist file if not exists installDefaultBlocklists fi - # Download or update the scripts by updating the appropriate git repos - clone_or_update_repos + # Download or reset the appropriate git repos depending on the 'repair' flag + clone_or_reset_repos # Create the pihole user From 7282aada25704631987ed35ffbf5c5bdb7412404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 28 Feb 2025 11:51:09 +0100 Subject: [PATCH 3/3] Don't show a warning before the repair is done MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 44 ++---------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 05219357..1d154cfe 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1787,40 +1787,6 @@ displayFinalMessage() { \\n${additional}" "${r}" "${c}" } -repair_dialog() { - # pihole -r/--repair option was selected - # set some variables that will be used - opt1a="Repair" - opt1b="This will retain existing settings" - strAdd="You will remain on the same version" - - # Display the information to the user - UpdateCmd=$(dialog --no-shadow --keep-tite --output-fd 1 \ - --cancel-label Exit \ - --title "Existing Install Detected!" \ - --menu "\\n\\nWe have detected an existing install.\ -\\n\\nPlease choose from the following options:\ -\\n($strAdd)" \ - "${r}" "${c}" 1 \ - "${opt1a}" "${opt1b}") || result=$? - - case ${result} in - "${DIALOG_CANCEL}" | "${DIALOG_ESC}") - printf " %b Cancel was selected, exiting installer%b\\n" "${COL_LIGHT_RED}" "${COL_NC}" - exit 1 - ;; - esac - - # Set the variable based on if the user chooses - case ${UpdateCmd} in - # repair - "${opt1a}") - printf " %b %s option selected\\n" "${INFO}" "${opt1a}" - useUpdateVars=true - ;; - esac -} - check_download_exists() { # Check if the download exists and we can reach the server local status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1) @@ -2430,19 +2396,15 @@ main() { exit 1 fi - # in case of an update (can be a v5 -> v6 or v6 -> v6 update) + # in case of an update (can be a v5 -> v6 or v6 -> v6 update) or repair if [[ -f "${PI_HOLE_V6_CONFIG}" ]] || [[ -f "/etc/pihole/setupVars.conf" ]]; then + # retain settings + useUpdateVars=true # if it's running unattended, if [[ "${runUnattended}" == true ]]; then printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}" - # Use the setup variables - useUpdateVars=true # also disable debconf-apt-progress dialogs export DEBIAN_FRONTEND="noninteractive" - else - # If running attended, show the available options (repair/cancel) - # if repair is selected useUpdateVars will be 'true' - repair_dialog fi fi