05cd261
#!/bin/sh
05cd261
#
05cd261
# Startup script for the DNS caching server
05cd261
#
05cd261
# chkconfig: - 49 50
05cd261
# description: This script starts your DNS caching server
05cd261
# processname: dnsmasq
05cd261
# pidfile: /var/run/dnsmasq.pid
05cd261
05cd261
# Source function library.
05cd261
. /etc/rc.d/init.d/functions
05cd261
05cd261
# Source networking configuration.
05cd261
. /etc/sysconfig/network
05cd261
05cd261
# Check that networking is up.
05cd261
[ ${NETWORKING} = "no" ] && exit 0
05cd261
05cd261
dnsmasq=/usr/sbin/dnsmasq
05cd261
[ -f $dnsmasq ] || exit 0
05cd261
05cd261
DOMAIN_SUFFIX=`dnsdomainname`
05cd261
if [ ! -z "${DOMAIN_SUFFIX}" ]; then
05cd261
  OPTIONS="-s $DOMAIN_SUFFIX"
05cd261
fi
05cd261
c93eaf9
pidfile=${PIDFILE-/var/run/dnsmasq.pid}
c93eaf9
lockfile=${LOCKFILE-/var/lock/subsys/dnsmasq}
c93eaf9
c93eaf9
05cd261
RETVAL=0
05cd261
05cd261
# See how we were called.
05cd261
case "$1" in
05cd261
  start)
05cd261
        echo -n "Starting dnsmasq: "
05cd261
        daemon $dnsmasq $OPTIONS
05cd261
	RETVAL=$?
05cd261
        echo
c93eaf9
        [ $RETVAL -eq 0 ] && touch ${lockfile}
05cd261
        ;;
05cd261
  stop)
c93eaf9
        echo -n "Shutting down dnsmasq: "
c93eaf9
        killproc -p ${pidfile} ${dnsmasq}
05cd261
	RETVAL=$?
05cd261
        echo
c93eaf9
        [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile}
05cd261
        ;;
05cd261
  status)
05cd261
	status dnsmasq
05cd261
	RETVAL=$?
05cd261
	;;
05cd261
  reload)
05cd261
	echo -n "Reloading dnsmasq: "
c93eaf9
	killproc -p ${pidfile} ${dnsmasq} -HUP
05cd261
	RETVAL=$?
05cd261
	echo
05cd261
	;;
05cd261
  restart)
05cd261
	$0 stop
05cd261
	$0 start
05cd261
	RETVAL=$?
05cd261
	;;
05cd261
  condrestart)
c93eaf9
	    if test "x`pidfileofproc dnsmasq`" != x; then
05cd261
		$0 stop
05cd261
		$0 start
05cd261
		RETVAL=$?
05cd261
	    fi
05cd261
	    ;;
05cd261
  *)
05cd261
        echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
05cd261
        exit 1
05cd261
esac
05cd261
05cd261
exit $RETVAL
05cd261