#!/bin/sh
#
# maui	This script will start and stop the MAUI Scheduler
#
# chkconfig: 345 85 85
# description: maui
#
ulimit -n 32768
# Source the library functions
. /etc/rc.d/init.d/functions

[ -f /etc/sysconfig/maui ] && . /etc/sysconfig/maui

# let see how we were called
case "$1" in
	start) 
		echo -n "Starting MAUI Scheduler: "
		daemon /usr/sbin/maui $MAUI_FLAGS
                RETVAL=$?
		echo
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/maui
		;;
	stop)
                PID=`/sbin/pidof /usr/sbin/maui` 
		echo -n "Shutting down MAUI Scheduler: "
		( /usr/bin/schedctl $SCHEDCTL_SHUTDOWN > /dev/null && /bin/sleep 1 && success ) || failure
                RETVAL=$?
		echo  
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/maui
		;;
	status)
		status maui
		;;
	restart)
		$0 stop
		$0 start
		;;
	condrestart)
		if [ -f /var/lock/subsys/maui ]; then
			$0 stop
			$0 start
		fi 
		;;
	*)
		echo "Usage: maui {start|stop|restart|status}"
		exit 1
esac
