1#! /bin/sh
2#
3# init.d/dnsmasq
4#
5### BEGIN INIT INFO
6# Provides:       dnsmasq
7# Required-Start: $network $remote_fs $syslog
8# Required-Stop:
9# Default-Start:  3 5
10# Default-Stop:
11# Description:    Starts internet name service masq caching server (DNS)
12### END INIT INFO
13
14NAMED_BIN=/usr/sbin/dnsmasq
15NAMED_PID=/var/run/dnsmasq.pid
16NAMED_CONF=/etc/dnsmasq.conf
17
18if [ ! -x $NAMED_BIN ] ; then
19	echo -n "dnsmasq not installed ! "
20	exit 5
21fi
22
23. /etc/rc.status
24rc_reset
25
26case "$1" in
27    start)
28	echo -n "Starting name service masq caching server "
29        checkproc -p $NAMED_PID $NAMED_BIN
30        if [ $? -eq 0 ] ; then
31           echo -n "- Warning: dnsmasq already running ! "
32        else
33           [ -e $NAMED_PID ] && echo -n "- Warning: $NAMED_PID exists ! "
34	fi
35	startproc -p $NAMED_PID $NAMED_BIN -u nobody
36	rc_status -v
37	;;
38    stop)
39	echo -n "Shutting name service masq caching server "
40	checkproc -p $NAMED_PID $NAMED_BIN
41	[ $? -ne 0 ] && echo -n "- Warning: dnsmasq not running ! "
42	killproc -p $NAMED_PID -TERM $NAMED_BIN
43	rc_status -v
44	;;
45    try-restart)
46	$0 stop  &&  $0 start
47	rc_status
48	;;
49    restart)
50	$0 stop
51	$0 start
52	rc_status
53	;;
54    force-reload)
55	$0 reload
56	rc_status
57	;;
58    reload)
59	echo -n "Reloading name service masq caching server "
60	checkproc -p $NAMED_PID $NAMED_BIN
61	[ $? -ne 0 ] && echo -n "- Warning: dnsmasq not running ! "
62	killproc -p $NAMED_PID -HUP $NAMED_BIN
63	rc_status -v
64	;;
65    status)
66	echo -n "Checking for name service masq caching server "
67	checkproc -p $NAMED_PID $NAMED_BIN
68	rc_status -v
69	;;
70    probe)
71	test $NAMED_CONF -nt $NAMED_PID && echo reload
72	;;
73    *)
74	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
75	exit 1
76	;;
77esac
78rc_exit
79
80