Use pkill instead of the somewhat fragile combination of kill + pidof. This solves some issues especially when there are many TCP workers floating around.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2020-07-21 21:13:40 +02:00
parent 643d2c0f3e
commit 6ee6eea1fb
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

10
pihole
View file

@ -20,8 +20,6 @@ PI_HOLE_BIN_DIR="/usr/local/bin"
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE" readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
source "${colfile}" source "${colfile}"
resolver="pihole-FTL"
webpageFunc() { webpageFunc() {
source "${PI_HOLE_SCRIPT_DIR}/webpage.sh" source "${PI_HOLE_SCRIPT_DIR}/webpage.sh"
main "$@" main "$@"
@ -107,19 +105,19 @@ restartDNS() {
# Determine if we should reload or restart # Determine if we should reload or restart
if [[ "${svcOption}" =~ "reload-lists" ]]; then if [[ "${svcOption}" =~ "reload-lists" ]]; then
# Reloading of the lists has been requested # Reloading of the lists has been requested
# Note: This will NOT re-read any *.conf files # Note 1: This will NOT re-read any *.conf files
# Note 2: We cannot use killall here as it does # Note 2: We cannot use killall here as it does
# not know about real-time signals # not know about real-time signals
svc="kill -SIGRTMIN $(pidof ${resolver})" svc="pkill -RTMIN pihole-FTL"
str="Reloading DNS lists" str="Reloading DNS lists"
elif [[ "${svcOption}" =~ "reload" ]]; then elif [[ "${svcOption}" =~ "reload" ]]; then
# Reloading of the DNS cache has been requested # Reloading of the DNS cache has been requested
# Note: This will NOT re-read any *.conf files # Note: This will NOT re-read any *.conf files
svc="killall -s SIGHUP ${resolver}" svc="pkill -HUP pihole-FTL"
str="Flushing DNS cache" str="Flushing DNS cache"
else else
# A full restart has been requested # A full restart has been requested
svc="service ${resolver} restart" svc="service pihole-FTL restart"
str="Restarting DNS server" str="Restarting DNS server"
fi fi