gplv3/dnsmasq/files/init

60 lines
1.2 KiB
Bash

#!/bin/sh
if [ -f /etc/centos-release ]; then
DAEMON=/usr/sbin/dnsmasq
else
DAEMON=/usr/bin/dnsmasq
fi
NAME=dnsmasq
DESC="DNS forwarder and DHCP server"
PIDFILE="/var/run/dnsmasq.pid"
test -f $DAEMON || exit 0
case "$1" in
start)
echo -n "starting $DESC: $NAME... "
test -d /var/lib/misc/ || mkdir /var/lib/misc/
start-stop-daemon -S -x $DAEMON --pidfile $PIDFILE -- $ARGS
echo "done."
echo -n "Refresh hosts cache"
nscd -i hosts
echo "done."
;;
stop)
echo -n "stopping $DESC: $NAME... "
start-stop-daemon -K -x $DAEMON --pidfile $PIDFILE
rm -f $PIDFILE
echo "done."
;;
status)
echo -n "dnsmasq "
start-stop-daemon -q -K -t -x $DAEMON --pidfile $PIDFILE
RET=$?
if [ "$RET" = "0" ]; then
PID=`cat $PIDFILE`
echo "($PID) is running"
else
echo "is not running"
# For lsb compliance return 3 if process not running
exit 3
fi
;;
restart)
echo "restarting $DESC: $NAME... "
$0 stop
$0 start
echo "done."
;;
reload)
echo -n "reloading $DESC: $NAME... "
killall -HUP $(basename ${DAEMON})
echo "done."
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload}"
exit 1
;;
esac
exit 0