#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=lwresd
DAEMON=/usr/sbin/lwresd

# Don't modify this line, change or create /etc/default/lwresd.
OPTIONS=""

test -f /etc/default/lwresd && . /etc/default/lwresd

test -x $DAEMON || exit 0

case "$1" in
    start)
	modprobe capability >/dev/null 2>&1 || true

	# dirs under /var/run can go away on reboots.
	mkdir -p /var/run/bind/run
	chmod 775 /var/run/bind/run
	chown root:bind /var/run/bind/run >/dev/null 2>&1 || true

	echo -n "Starting domain name service: $NAME"
	start-stop-daemon --start --quiet --exec $DAEMON  -- $OPTIONS
	echo "."	
    ;;

    stop)
	echo -n "Stopping domain name service: $NAME"
	start-stop-daemon --stop --quiet  \
	    --pidfile /var/run/bind/run/$NAME.pid --exec $DAEMON
	echo "."	
    ;;

    restart|force-reload)
	$0 stop
	sleep 2
	$0 start
    ;;
    
    *)
	echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
	exit 1
    ;;
esac

exit 0
