#!/bin/ksh
#
# ident "@(#)utjrectl.ksh	1.3	05/06/01 SMI"
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

set -u

########################################################################
#
# Configures the JRE path in /etc/opt/SUNWut/jre
#
# NOTE: it does not check if the path contains the proper JRE version.
# It only checks to see if it's a valid directory.  If it's not a valid
# directory, it will display a warning message after creating the link.
# The tool that is adding the JRE information into the utctl.conf must
# verify the path.
#
########################################################################



########################################################################
#
# Operation entry points, one for each keyword.  This is where the
# specific work for this feature happens.
#
########################################################################


#
# disable()
#
disable() {

	if [ -L $JRE_LINK ] ; then
		/bin/rm -rf $JRE_LINK
		if $VERB; then
			print "JRE link disabled"
		fi
	fi
	return 0
}

#
# enable()
# NOTE: nothing will be done if the link already exists.
#
enable() {
	if [ ! -L $JRE_LINK ] ; then
		# link does not exist, enable it
		if [ ! -d "$JRE_PATHNAME" ]; then
			print -u2 "${PROG}: warning - $JRE_PATHNAME does not exist"
		fi
		if /bin/ln -s $JRE_PATHNAME $JRE_LINK; then
			if $VERB; then
				print "JRE link enabled"
			fi
		else
			print -u2 "${PROG}: warning - failed to create the JRE link"
		fi
	fi
	return 0
}


#########################################
# LOCAL VARIABLES
# They must defined here to resolve the some of parameter resolution
# problem
#########################################
local_variables() {
	JRE_LINK=${SUNWUTETC}/jre
}


#########################################
#
# Configurable parameter
#
#########################################
JRE_PATHNAME=/usr/j2se

#########################################
#
# variables used in the shared script utctl-shlib
#
#########################################
PARAM="JRE_PATHNAME - pathname where Java is located"
DESCR="sets up the link to JRE home for Sun Ray programs"


########################################################################
#
# Execution starts here
#

PROGPATH=`dirname $0`
. $PROGPATH/utctl-shlib
