slackware-current/source/n/dnsmasq/rc.dnsmasq
Patrick J Volkerding 1e4e21c504 Sun Apr 25 19:00:34 UTC 2021
d/gdb-10.2-x86_64-1.txz:  Upgraded.
d/python-pip-21.1-x86_64-1.txz:  Upgraded.
n/dnsmasq-2.85-x86_64-2.txz:  Rebuilt.
  rc.dnsmasq: display stop message. Thanks to vineetmehta.
  rc.dnsmasq: kill by .pid file (or at least within the current namespace).
  Thanks to Petri Kaukasoina.
n/wireguard-tools-1.0.20210424-x86_64-1.txz:  Upgraded.
x/fcitx-qt5-1.2.6-x86_64-1.txz:  Upgraded.
2021-04-26 08:59:56 +02:00

43 lines
814 B
Bash

#!/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() {
# 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
}
# 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