Remove the restartdns functionality and promote the reloaddns functions (#5780)

This commit is contained in:
Adam Warner 2024-10-02 21:27:08 +01:00 committed by GitHub
commit 7dd2eb20a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 59 additions and 67 deletions

View file

@ -7,7 +7,7 @@ _pihole() {
case "${prev}" in case "${prev}" in
"pihole") "pihole")
opts="allow allow-regex allow-wild deny checkout debug disable enable flush help logging query reconfigure regex restartdns status tail uninstall updateGravity updatePihole version wildcard arpflush api" 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"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;; ;;
"allow"|"deny"|"wildcard"|"regex"|"allow-regex"|"allow-wild") "allow"|"deny"|"wildcard"|"regex"|"allow-regex"|"allow-wild")

View file

@ -236,16 +236,14 @@ Available commands and options:
#m Disable Pi-hole functionality for # minute(s) #m Disable Pi-hole functionality for # minute(s)
.br .br
\fBrestartdns\fR [options] \fBreloaddns\fR
.br .br
Full restart Pi-hole subsystems. Without any options (see below) a full restart causes config file parsing and history re-reading Update the lists and flush the cache without restarting the DNS server
.br .br
(restart options): \fBreloadlists\fR
.br .br
reload Updates the lists (incl. HOSTS files) and flushes DNS cache. Does not reparse config files Update the lists WITHOUT flushing the cache or restarting the DNS server
.br
reload-lists Updates the lists (excl. HOSTS files) WITHOUT flushing the DNS cache. Does not reparse config files
.br .br
\fBcheckout\fR [repo] [branch] \fBcheckout\fR [repo] [branch]

114
pihole
View file

@ -147,9 +147,9 @@ versionFunc() {
exec "${PI_HOLE_SCRIPT_DIR}"/version.sh exec "${PI_HOLE_SCRIPT_DIR}"/version.sh
} }
restartDNS() { reloadDNS() {
local svcOption svc str output status pid icon FTL_PID_FILE local svcOption svc str output status pid icon FTL_PID_FILE
svcOption="${1:-restart}" svcOption="${1:-reload}"
# get the current path to the pihole-FTL.pid # get the current path to the pihole-FTL.pid
FTL_PID_FILE="$(getFTLConfigValue files.pid)" FTL_PID_FILE="$(getFTLConfigValue files.pid)"
@ -184,11 +184,6 @@ restartDNS() {
str="Flushing DNS cache" str="Flushing DNS cache"
icon="${TICK}" icon="${TICK}"
fi fi
else
# A full restart has been requested
svc="service pihole-FTL restart"
str="Restarting DNS server"
icon="${TICK}"
fi fi
# Print output to Terminal, but not to Web Admin # Print output to Terminal, but not to Web Admin
@ -509,9 +504,8 @@ Options:
enable Enable Pi-hole subsystems enable Enable Pi-hole subsystems
disable Disable Pi-hole subsystems disable Disable Pi-hole subsystems
Add '-h' for more info on disable usage Add '-h' for more info on disable usage
restartdns Full restart Pi-hole subsystems reloaddns Update the lists and flush the cache without restarting the DNS server
Add 'reload' to update the lists and flush the cache without restarting the DNS server reloadlists Update the lists WITHOUT flushing the cache or restarting the DNS server
Add 'reload-lists' to only update the lists WITHOUT flushing the cache or restarting the DNS server
checkout Switch Pi-hole subsystems to a different GitHub branch checkout Switch Pi-hole subsystems to a different GitHub branch
Add '-h' for more info on checkout usage Add '-h' for more info on checkout usage
arpflush Flush information stored in Pi-hole's network tables"; arpflush Flush information stored in Pi-hole's network tables";
@ -525,38 +519,38 @@ fi
# functions that do not require sudo power # functions that do not require sudo power
need_root=1 need_root=1
case "${1}" in case "${1}" in
"-h" | "help" | "--help" ) helpFunc;; "-h" | "help" | "--help" ) helpFunc;;
"-v" | "version" ) versionFunc;; "-v" | "version" ) versionFunc;;
"-c" | "chronometer" ) chronometerFunc "$@";; "-c" | "chronometer" ) chronometerFunc "$@";;
"-q" | "query" ) queryFunc "$@";; "-q" | "query" ) queryFunc "$@";;
"status" ) statusFunc "$2";; "status" ) statusFunc "$2";;
"tricorder" ) tricorderFunc;; "tricorder" ) tricorderFunc;;
# we need to add all arguments that require sudo power to not trigger the * argument # we need to add all arguments that require sudo power to not trigger the * argument
"allow" | "allowlist" ) need_root=0;; "allow" | "allowlist" ) need_root=0;;
"deny" | "denylist" ) need_root=0;; "deny" | "denylist" ) need_root=0;;
"--wild" | "wildcard" ) need_root=0;; "--wild" | "wildcard" ) need_root=0;;
"--regex" | "regex" ) need_root=0;; "--regex" | "regex" ) need_root=0;;
"--allow-regex" | "allow-regex" ) need_root=0;; "--allow-regex" | "allow-regex" ) need_root=0;;
"--allow-wild" | "allow-wild" ) need_root=0;; "--allow-wild" | "allow-wild" ) need_root=0;;
"-f" | "flush" ) ;; "-f" | "flush" ) ;;
"-up" | "updatePihole" ) ;; "-up" | "updatePihole" ) ;;
"-r" | "reconfigure" ) ;; "-r" | "reconfigure" ) ;;
"-l" | "logging" ) ;; "-l" | "logging" ) ;;
"uninstall" ) ;; "uninstall" ) ;;
"enable" ) need_root=0;; "enable" ) need_root=0;;
"disable" ) need_root=0;; "disable" ) need_root=0;;
"-d" | "debug" ) ;; "-d" | "debug" ) ;;
"restartdns" ) ;; "-g" | "updateGravity" ) ;;
"-g" | "updateGravity" ) ;; "reloaddns" ) ;;
"reloaddns" ) ;; "reloadlists" ) ;;
"setpassword" ) ;; "setpassword" ) ;;
"checkout" ) ;; "checkout" ) ;;
"updatechecker" ) ;; "updatechecker" ) ;;
"arpflush" ) ;; "arpflush" ) ;;
"-t" | "tail" ) ;; "-t" | "tail" ) ;;
"api" ) need_root=0;; "api" ) need_root=0;;
* ) helpFunc;; * ) helpFunc;;
esac esac
# In the case of alpine running in a container, the USER variable appears to be blank # In the case of alpine running in a container, the USER variable appears to be blank
@ -575,28 +569,28 @@ fi
# Handle redirecting to specific functions based on arguments # Handle redirecting to specific functions based on arguments
case "${1}" in case "${1}" in
"allow" | "allowlist" ) listFunc "$@";; "allow" | "allowlist" ) listFunc "$@";;
"deny" | "denylist" ) listFunc "$@";; "deny" | "denylist" ) listFunc "$@";;
"--wild" | "wildcard" ) listFunc "$@";; "--wild" | "wildcard" ) listFunc "$@";;
"--regex" | "regex" ) listFunc "$@";; "--regex" | "regex" ) listFunc "$@";;
"--allow-regex" | "allow-regex" ) listFunc "$@";; "--allow-regex" | "allow-regex" ) listFunc "$@";;
"--allow-wild" | "allow-wild" ) listFunc "$@";; "--allow-wild" | "allow-wild" ) listFunc "$@";;
"-d" | "debug" ) debugFunc "$@";; "-d" | "debug" ) debugFunc "$@";;
"-f" | "flush" ) flushFunc "$@";; "-f" | "flush" ) flushFunc "$@";;
"-up" | "updatePihole" ) updatePiholeFunc "$@";; "-up" | "updatePihole" ) updatePiholeFunc "$@";;
"-r" | "reconfigure" ) reconfigurePiholeFunc;; "-r" | "reconfigure" ) reconfigurePiholeFunc;;
"-g" | "updateGravity" ) updateGravityFunc "$@";; "-g" | "updateGravity" ) updateGravityFunc "$@";;
"-l" | "logging" ) piholeLogging "$@";; "-l" | "logging" ) piholeLogging "$@";;
"uninstall" ) uninstallFunc;; "uninstall" ) uninstallFunc;;
"enable" ) piholeEnable true "$2";; "enable" ) piholeEnable true "$2";;
"disable" ) piholeEnable false "$2";; "disable" ) piholeEnable false "$2";;
"restartdns" ) restartDNS "$2";; "reloaddns" ) reloadDNS "reload";;
"reloaddns" ) restartDNS "reload";; "reloadlists" ) reloadDNS "reload-lists";;
"setpassword" ) SetWebPassword "$@";; "setpassword" ) SetWebPassword "$@";;
"checkout" ) piholeCheckoutFunc "$@";; "checkout" ) piholeCheckoutFunc "$@";;
"updatechecker" ) shift; updateCheckFunc "$@";; "updatechecker" ) shift; updateCheckFunc "$@";;
"arpflush" ) arpFunc "$@";; "arpflush" ) arpFunc "$@";;
"-t" | "tail" ) tailFunc "$2";; "-t" | "tail" ) tailFunc "$2";;
"api" ) apiFunc "$2";; "api" ) apiFunc "$2";;
* ) helpFunc;; * ) helpFunc;;
esac esac