Use systemctl/service calls instead of killall to restart/reload dnsmasq

This commit is contained in:
Promofaux 2016-10-16 17:16:59 +01:00
parent df30a4c0d1
commit 8c0f860601
3 changed files with 40 additions and 17 deletions

View file

@ -172,11 +172,19 @@ Reload() {
if [[ ${dnsmasqPid} ]]; then
# service already running - reload config
killall -s HUP dnsmasq
if [ -x "$(command -v systemctl)" ]; then
systemctl restart dnsmasq
else
service dnsmasq restart
fi
else
# service not running, start it up
if [ -x "$(command -v systemctl)" ]; then
systemctl start dnsmasq
else
service dnsmasq start
fi
fi
echo " done!"
}

View file

@ -189,11 +189,19 @@ Reload() {
if [[ ${dnsmasqPid} ]]; then
# service already running - reload config
killall -s HUP dnsmasq
if [ -x "$(command -v systemctl)" ]; then
systemctl restart dnsmasq
else
service dnsmasq restart
fi
else
# service not running, start it up
if [ -x "$(command -v systemctl)" ]; then
systemctl start dnsmasq
else
service dnsmasq start
fi
fi
echo " done!"
}

View file

@ -310,18 +310,25 @@ gravity_reload() {
adList=${adList//\//\\\/}
#Now replace the line in dnsmasq file
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
dnsmasqPid=$(pidof dnsmasq)
find "$piholeDir" -type f -exec chmod 666 {} \;
dnsmasqPid=$(pidof dnsmasq)
if [[ ${dnsmasqPid} ]]; then
# service already running - reload config
killall -s HUP dnsmasq
if [ -x "$(command -v systemctl)" ]; then
systemctl restart dnsmasq
else
service dnsmasq restart
fi
else
# service not running, start it up
if [ -x "$(command -v systemctl)" ]; then
systemctl start dnsmasq
else
service dnsmasq start
fi
echo " done!"
fi
}