#!/sbin/sh
#
# @(#) $Revision: 1.1 $
#
# WARNING: Changing this script may lead to a system that
#          is unbootable.  Do not modify this script.

#
# File for automatic startup of SIGMET IRIS.
#

# Allowed exit values:
#	0 = success; causes "OK" to show up in checklist.
#	1 = failure; causes "FAIL" to show up in checklist.
#	2 = skip; causes "N/A" to show up in the checklist.
#           Use this value if execution of this script is overridden
#	    by the use of a control variable, or if this script is not
#	    appropriate to execute for some other reason.
#       3 = reboot; causes the system to be rebooted after execution.

# Input and output:
#	stdin is redirected from /dev/null
#
#	stdout and stderr are redirected to the /etc/rc.log file
#	during checklist mode, or to the console in raw mode.

PATH=/usr/sbin:/usr/bin:/sbin
export PATH

rval=0

# Check the exit value of a command run by this script.  If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.

set_return() {
	x=$?
	if [ $x -ne 0 ]; then
		echo "EXIT CODE: $x"
		rval=1	# script FAILed
	fi
}



case $1 in
'start_msg')
	echo "Starting the IRIS Radar subsystem"
	;;

'stop_msg')
	echo "Stopping the IRIS Radar subsystem"
	;;

'start')
	# Execute the commands to start your subsystem
	if [ -x /usr/sigmet/bin/siris ] ; then
		su - operator -c "/usr/sigmet/bin/siris -auto"
		set_return
	else
		echo "ERROR: /usr/sigmet/bin/siris file missing"
		rval=1
	fi
	;;

'stop')
	:
	# Execute the commands to stop your subsystem
	if [ -x /usr/sigmet/bin/qiris ] ; then
		su - operator -c "/usr/sigmet/bin/qiris -auto"
		set_return
	else
		echo "ERROR: /usr/sigmet/bin/qiris file missing"
		rval=1
	fi

	;;

*)
	echo "usage: $0 {start|stop|start_msg|stop_msg}"
	rval=1
	;;
esac

exit $rval
