LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File rc.dnsmasq-suse of Package dnsmasq (Project home:StefanBruens:branches:network)

#! /bin/sh
#
# init.d/dnsmasq
#
### BEGIN INIT INFO
# Provides:       dnsmasq
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start:  3 5
# Default-Stop:
# Description:    Starts internet name service masq caching server (DNS)
### END INIT INFO

NAMED_BIN=/usr/sbin/dnsmasq
NAMED_PID=/var/run/dnsmasq.pid
NAMED_CONF=/etc/dnsmasq.conf

if [ ! -x $NAMED_BIN ] ; then
	echo -n "dnsmasq not installed! "
	exit 5
fi

. /etc/rc.status
rc_reset

case "$1" in
    start)
        if grep "^[^#].*/etc/ppp/" /etc/dnsmasq.conf >/dev/null 2>&1; then
                echo
                echo "Warning! dnsmasq can not read the /etc/ppp directory anymore";
                echo "         but /etc/ppp seems to be used in your config";
                echo "         use /var/run/ instead like /var/run/dnsmasq-forwarders.conf";
                echo
        fi
	echo -n "Starting name service masq caching server "
        checkproc -p $NAMED_PID $NAMED_BIN
        if [ $? -eq 0 ] ; then
           echo -n "- Warning: dnsmasq already running! "
        else
           [ -e $NAMED_PID ] && echo -n "- Warning: $NAMED_PID exists! "
	fi
	startproc -p $NAMED_PID $NAMED_BIN -u dnsmasq
	rc_status -v
	;;
    stop)
	echo -n "Shutting name service masq caching server "
	checkproc -p $NAMED_PID $NAMED_BIN
	[ $? -ne 0 ] && echo -n "- Warning: dnsmasq not running! "
	killproc -p $NAMED_PID -TERM $NAMED_BIN
	rc_status -v
	;;
    try-restart|force-reload)
	if $0 status ; then
		$0 restart
	else
		rc_reset
	fi
	rc_status
	;;
    restart)
        if checkproc -p $NAMED_PID $NAMED_BIN ; then
		$0 stop
	fi
	$0 start
	rc_status
	;;
    reload)
	echo -n "Reloading name service masq caching server unsupported "
	rc_failed 3
	rc_status -v
	;;
    sighup)
	echo -n "Sending SIGHUP to name service masq caching server "
	killproc -p $NAMED_PID -HUP $NAMED_BIN
	rc_status -v
	;;
    status)
	echo -n "Checking for name service masq caching server "
	checkproc -p $NAMED_PID $NAMED_BIN
	rc_status -v
	;;
    probe)
	test $NAMED_CONF -nt $NAMED_PID && echo reload
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|sighup|probe}"
	exit 1
	;;
esac
rc_exit