diff options
author | Christian König <ckoenig@posteo.de> | 2022-09-30 09:55:39 +0300 |
---|---|---|
committer | Christian König <ckoenig@posteo.de> | 2022-09-30 09:55:39 +0300 |
commit | 6c8f5aa4a2a765393b4c56058ede274003df0eb9 (patch) | |
tree | 7b2e764a2971d8ea6f7ea74c6cecab75e4d6c839 | |
parent | a705fbca7323ab7a134600aa662b187e23b25ece (diff) |
Use systemctl for `pihole restartdns` if available
Signed-off-by: Christian König <ckoenig@posteo.de>
-rwxr-xr-x | pihole | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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 |