#!/bin/sh
#
# Startup script file for the Sonnet Emserver.  This server allows
# remote em jobs to be run on this server.
#
# You should copy this file into /etc/rc3.d
#
# Must define SONNET_DIR environment variable in this script

########## MUST SET FOLLOWING VARIABLE TO POINT TO THE SONNET DIRECTORY
########## Make sure you remove the "#" character to uncomment the line.
#SONNET_DIR=

########## To allow all users to have read/write permissions to 
# Files created by em running from emserver, set SONNET_UMASK to 000 
#SONNET_UMASK=000
export SONNET_DIR SONNET_UMASK

if [ "$SONNET_DIR" = "" ]
then
	echo ERROR: SONNET_DIR variable is not set
	exit 1
fi

if [ ! -d "$SONNET_DIR" ]
then
	echo "ERROR: SONNET_DIR does not point to a directory (SONNET_DIR=$SONNET_DIR)"
	exit 1
fi


if [ ! -f "$SONNET_DIR/sonnet.ver" ]
then
	echo "ERROR: SONNET_DIR does not point to a directory (SONNET_DIR=$SONNET_DIR)"
	exit 1
fi


case "$1" in 
	start)	
		# Start the sonnet emserver
		echo Starting Sonnet Software emserver
		$SONNET_DIR/bin/emserver -DaemonProcess &
		;;
	stop)
		# Stop the sonnet emserver
		echo Stopping Sonnet Software emserver
		$SONNET_DIR/bin/emclient -SHUTDOWN &
		;;
esac




