#!/bin/bash
#
# chkconfig: 345 95 05
# description: wwnewd listens for new nodes, and configures them as they are
#              found.
# processname: wwnewd
# pidfile: /var/run/wwnewd.pid

# source function library
. /etc/init.d/functions

RETVAL=0

start() {
   if [ -x /usr/sbin/wwnewd ]; then
      gprintf "Starting wwnewd: "
      if [ -f /var/run/wwnewd.pid ]; then
         status wwnewd
         exit 1
      else
         daemon /usr/sbin/wwnewd </dev/null
         RETVAL=$?
         echo
      fi
   fi
}

stop() {
   if [ -f /var/run/wwnewd.pid ]; then
      gprintf "Shutting down wwnewd: "
      killproc wwnewd
      RETVAL=$?
      echo
   fi
   test -f /var/run/wwnnewd 		&& rm -f /var/run/wwnewd
   test -f /var/lock/subsys/wwnewd 	&& rm -f /var/lock/subsys/wwnewd
}

stats() {
   if [ -x /usr/sbin/wwnewd ]; then
      status wwnewd
      RETVAL=0
   fi
}

case "$1" in
  start)
   start
   ;;
  stop)
   stop
   ;;
  restart)
   stop
   start
   RETVAL=0
   ;;
#  reload)
 #  reload
 #  ;;
  status)
   stats
   ;;
  *)
   gprintf "Usage: %s {start|stop|restart|status}\n" "$0"
   exit 1
esac

exit $RETVAL
