#!/bin/sh
# 
# Author: Nico Schottelius <nico AT schottelius DOT org>
# Date: 6th of May 2k+1
# Last Changed: 18th of May 2k+1
# Comment: Support for devfs
#

. /etc/sys/combined
. /etc/sys/boot/devfs

test `basename $0` = devfs && START_DEVFS="yes"
test "$START_DEVFS" = yes || exit 0

CHECK_DEVFS=`cat /proc/mounts | grep devfs | awk '{ print $1 }'`

# Check whether devfs is mounted
if [ -z "$CHECK_DEVFS ]; then
  $SYS_ECHO $FAIL $NO_DEVFS_THERE
  exit 1
fi

case "$1" in
    start)	$SYS_ECHO "$START $DEVFS_TEXT"
		
		startproc /usr/sbin/named -u $NAMED_USER -g $NAMED_GROUP \
		|| ( $SYS_ECHO "$FAIL" ; exit 1)
		$SYS_ECHO $DONE
		;;
    stop)	$SYS_ECHO -n "$STOP $NAMED_TEXT "
    		killproc -TERM /usr/sbin/named || ( $SYS_ECHO "$FAIL" ; exit 1)
		$SYS_ECHO $DONE
		;;
    restart)
		$0 stop && $0 start
		;;
    reload)   	$SYS_ECHO -n "$RELOAD $NAMED_TEXT "
              	killproc -HUP /usr/sbin/named || ( $SYS_ECHO "$FAIL" ; exit 1)
		$SYS_ECHO $DONE
              	;;
    status)	checkproc /usr/sbin/named && $SYS_ECHO $OK || $SYS_ECHO $NOP
    		;;
    *)		$SYS_ECHO  "$USAGE $0 {start|stop|restart|reload|status}"
		exit 1
esac

exit 0
