mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-01-11 14:34:44 +00:00
Use systemctl/service calls instead of killall to restart/reload dnsmasq
This commit is contained in:
parent
df30a4c0d1
commit
8c0f860601
3 changed files with 40 additions and 17 deletions
|
@ -168,14 +168,22 @@ Reload() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
echo -n "::: Refresh lists in dnsmasq..."
|
||||||
|
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ ${dnsmasqPid} ]]; then
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
killall -s HUP dnsmasq
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
service dnsmasq start
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,14 +185,22 @@ Reload() {
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
echo -n "::: Refresh lists in dnsmasq..."
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ ${dnsmasqPid} ]]; then
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
killall -s HUP dnsmasq
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
service dnsmasq start
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
21
gravity.sh
21
gravity.sh
|
@ -310,18 +310,25 @@ gravity_reload() {
|
||||||
adList=${adList//\//\\\/}
|
adList=${adList//\//\\\/}
|
||||||
#Now replace the line in dnsmasq file
|
#Now replace the line in dnsmasq file
|
||||||
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
find "$piholeDir" -type f -exec chmod 666 {} \;
|
||||||
|
|
||||||
find "$piholeDir" -type f -exec chmod 666 {} \;
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
if [[ ${dnsmasqPid} ]]; then
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
killall -s HUP dnsmasq
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
service dnsmasq start
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue