#!/bin/sh
#
#ident  "@(#)sws_tp     2.4     96/10/08 SMI"
#
# Copyright (c) 1996-1999 by Sun Microsystems, Inc.
#
# Sun Ray Admin Server start/stop script
# This script is generally in /etc/rc2.d
#
# Modify the variables below if you would like the script to work for
#  non-default locations.

SCRIPT_NAME=`basename $0`
SCRIPT_DIR=`dirname $0`

# If SCRIPT_DIR is not an absolute path name (i.e. it doesn't begin with a '/')
# then we try to find the absolute path name using 'pwd'.

case $SCRIPT_DIR in
/* )
	;;
 * )
	INVOKING_DIRECTORY=`/usr/bin/pwd`
	SCRIPT_DIR=$INVOKING_DIRECTORY/$SCRIPT_DIR
	;;
esac

BASEDIR=$SCRIPT_DIR/../..

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

# Start/stop Sun Ray Admin Server

case "$1" in
'start')

    grep "^utadmin[ 	]" /etc/opt/SUNWut/http/httpd-instances.conf 1>/dev/null 2>&1
    if [ $? = "0" ]; then
	echo "starting Sun Ray Admin Server ... \c"
	$BASEDIR/opt/SUNWut/http/bin/htserver start utadmin
	touch $BASEDIR/var/opt/SUNWut/http/.initialized
    fi
    ;;

'stop')

    grep "^utadmin[ 	]" /etc/opt/SUNWut/http/httpd-instances.conf 1>/dev/null 2>&1
    if [ $? = "0" ]; then
	echo "stopping Sun Ray Admin Server ... \c"
	$BASEDIR/opt/SUNWut/http/bin/htserver stop utadmin
    fi
    ;;

*)
    echo "Usage: $SCRIPT_NAME { start | stop }"
    ;;
esac
