2009-08-26 17:00:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Start/stop/restart dnsmasq (a small DNS/DHCP server):
|
|
|
|
|
|
|
|
# Start dnsmasq:
|
|
|
|
dnsmasq_start() {
|
|
|
|
if [ -x /usr/sbin/dnsmasq ]; then
|
|
|
|
echo "Starting dnsmasq: /usr/sbin/dnsmasq"
|
|
|
|
/usr/sbin/dnsmasq
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Stop dnsmasq:
|
|
|
|
dnsmasq_stop() {
|
2021-04-25 21:00:34 +02:00
|
|
|
# Try to use the .pid file first:
|
|
|
|
if pgrep -l -F /var/run/dnsmasq.pid 2> /dev/null | grep -q dnsmasq ; then
|
|
|
|
echo "Stopping dnsmasq."
|
|
|
|
pkill -F /var/run/dnsmasq.pid 2> /dev/null
|
|
|
|
else # kill any dnsmasq processes in this namespace:
|
|
|
|
echo "Stopping dnsmasq."
|
|
|
|
killall --ns $$ dnsmasq 2> /dev/null
|
|
|
|
fi
|
2009-08-26 17:00:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Restart dnsmasq:
|
|
|
|
dnsmasq_restart() {
|
|
|
|
dnsmasq_stop
|
|
|
|
sleep 1
|
|
|
|
dnsmasq_start
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
'start')
|
|
|
|
dnsmasq_start
|
|
|
|
;;
|
|
|
|
'stop')
|
|
|
|
dnsmasq_stop
|
|
|
|
;;
|
|
|
|
'restart')
|
|
|
|
dnsmasq_restart
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "usage rc.dnsmasq: start|stop|restart"
|
|
|
|
esac
|