Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <ckoenig@posteo.de>2022-09-30 09:55:39 +0300
committerChristian König <ckoenig@posteo.de>2022-09-30 09:55:39 +0300
commit6c8f5aa4a2a765393b4c56058ede274003df0eb9 (patch)
tree7b2e764a2971d8ea6f7ea74c6cecab75e4d6c839
parenta705fbca7323ab7a134600aa662b187e23b25ece (diff)
Use systemctl for `pihole restartdns` if available
Signed-off-by: Christian König <ckoenig@posteo.de>
-rwxr-xr-xpihole14
1 files changed, 13 insertions, 1 deletions
diff --git a/pihole b/pihole
index 1047d152..b9952049 100755
--- a/pihole
+++ b/pihole
@@ -23,6 +23,14 @@ source "${colfile}"
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
source "${utilsfile}"
+is_command() {
+ # Checks to see if the given command (passed as a string argument) exists on the system.
+ # The function returns 0 (success) if the command exists, and 1 if it doesn't.
+ local check_command="$1"
+
+ command -v "${check_command}" >/dev/null 2>&1
+}
+
webpageFunc() {
source "${PI_HOLE_SCRIPT_DIR}/webpage.sh"
main "$@"
@@ -139,7 +147,11 @@ restartDNS() {
fi
else
# A full restart has been requested
- svc="service pihole-FTL restart"
+ if is_command systemctl ; then
+ svc="systemctl restart pihole-FTL"
+ else
+ svc="service pihole-FTL restart"
+ fi
str="Restarting DNS server"
icon="${TICK}"
fi