#!/bin/ksh
#
# utsettings script
#
# Starts up Sun Ray 1 Settings Java GUI
#
# ident "@(#)utsettings.sh	1.22 02/12/03 SMI"
#
# Copyright 1998-1999,2002 Sun Microsystems, Inc.  All rights reserved.
#

SUNWUTLIB=$(pkginfo -r SUNWuto 2>/dev/null)/SUNWut/lib
SUNWUTJRE=$(pkginfo -r SUNWutj 2>/dev/null)/SUNWut/jre
SUNWUTETC=/etc/$(pkginfo -r SUNWuto 2>/dev/null)/SUNWut/

#
# If JAVA_HOME is set, use that Java interpreter.  Else, use the one
# in our default Java.
#
if [[ -z "$JAVA_HOME" ]]
then
	JAVA_HOME=$SUNWUTJRE
fi

if [[ -x $JAVA_HOME/bin/java ]]
then
	JAVA=$JAVA_HOME/bin/java
else
	JAVA=$JAVA_HOME/bin/jre
fi

#
# Set CLASSPATH so Java knows where to get our classes from.
#
CLASSPATH=$SUNWUTLIB/settings.jar:$SUNWUTLIB/sdk.jar:$SUNWUTLIB:$CLASSPATH
export CLASSPATH

#
# Set LD_LIBRARY_PATH so Java knows where to get C libraries (native
# methods) from.
#
if [[ -n "$LD_LIBRARY_PATH" ]]
then
	LD_LIBRARY_PATH=$SUNWUTLIB:$LD_LIBRARY_PATH
else
	LD_LIBRARY_PATH=$SUNWUTLIB
fi
export LD_LIBRARY_PATH

JAVADEFS=""

#
# If the Sun Ray access token can be discovered from the SUN_SUNRAY_TOKEN
# environment variable then pass its value into SettingsGUI as a system
# property.
#
if [[ -n "$SUN_SUNRAY_TOKEN" ]] ; then
	JAVADEFS="$JAVADEFS -DSUN_SUNRAY_TOKEN=$SUN_SUNRAY_TOKEN"
fi

#
# If the group-wide Data Store has been configured then tell SettingsGUI
# by setting a system property.
#
if [[ -f "$SUNWUTETC/utadmin.pw" ]] ; then
	JAVADEFS="$JAVADEFS -DSUN_SUNRAY_DATASTORE=true"
fi

#
# If SETTINGS_DEBUG is set, pass its value into SettingsGUI so it can
# be picked up as a system property.
#
if [[ -n "$SETTINGS_DEBUG" ]]
then
	echo "running SettingsGUI with debug options |$SETTINGS_DEBUG|"
	JAVADEFS="$JAVADEFS -DSETTINGS_DEBUG=$SETTINGS_DEBUG"
fi
exec $JAVA $JAVADEFS SettingsGUI "$@"

