#!/bin/sh
#
# chkconfig: - 60 60
# description: MARS is a NetWare compatible file and printer server. It \
#              lets you use a Linux machine as a file and print server for \
#              NetWare based clients using NetWare's native IPX protocol suite.
# processname: nwserv
# processname: nwbind
# processname: ncpserv
# config: /etc/nwserv.stations
# config: /etc/nwserv.conf
# pidfile: /var/run/nwserv.pid 

WITHOUT_RC_COMPAT=1

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

[ -x /usr/sbin/nwserv ] || exit 0

PIDFILE=/var/run/nwserv.pid
LOCKFILE=/var/lock/subsys/nwserv.lock
RETVAL=0


start() {
	echo -n "Starting NetWare emulator-server: "
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- nwserv
	RETVAL=$?
	return $RETVAL
}	

stop() {
	echo -n "Stopping NetWare emulator-server: "
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -QUIT --expect-user root -- nwserv
	RETVAL=$?
	return $RETVAL
}	

rhstatus() {
	status --pidfile "$PIDFILE" -- nwserv
	for s in nwbind ncpserv; do
	    status -- $s
	done
}	

reload() {
	msg_reloading mars_nwe
	stop_daemon --pidfile "$PIDFILE" --expect-user root -HUP -- nwserv
}	

restart() {
	stop
	start
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  reload)
  	reload
	;;
  condstop)
	if [ -e "$LOCKFILE" ]; then
		stop
	fi
	;;
  condrestart)
	if [ -e "$LOCKFILE" ]; then
		restart
	fi
	;;
  condreload)
	if [ -e "$LOCKFILE" ]; then
		reload
	fi
	;;
  status)
  	rhstatus --pidfile "$PIDFILE" -- nwserv
	exit $?
	;;

  *)
	echo "Usage: $0 {start|stop|status|restart|reload|condstop|condrestart|condreload}"
	exit 1
	;;
esac

exit $?

