#!/bin/sh
#
# chkconfig: - 60 40
# 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 

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

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

RETVAL=0


start() {
	echo -n $"Starting NetWare emulator-server: "
	daemon nwserv
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mars-nwe
	echo
	return $RETVAL
}	

stop() {
	echo -n $"Stopping NetWare emulator-server: "
	killall -QUIT nwserv
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mars-nwe
	echo
	return $RETVAL
}	

rhstatus() {
	status nwserv
	status nwbind
	status ncpserv
}	

reload() {
	killall -HUP nwserv
}	

restart() {
	stop
	start
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  reload)
  	reload
	;;
  condrestart)
  	[ -f /var/lock/subsys/mars-nwe ] && restart || :
	;;
  status)
  	rhstatus
	;;

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

exit $?