#!/bin/ksh -p
#
# ident "@(#)utsettings.sh	1.25 04/09/29 SMI"
#
# Copyright 1998-1999,2002,2004 Sun Microsystems, Inc.  All rights reserved.
#
# Starts up Sun Ray Settings Java GUI
#

SUNWUT=$(/etc/opt/SUNWut/basedir/lib/utprodinfo -r SUNWuto)/SUNWut
SUNWUTLIB=$SUNWUT/lib
SUNWUTETC=/etc/opt/SUNWut

#
# Purpose of the new symlink - guijre :
# Pre 1.5 JRE releases cannot handle multibyte encodings with
# certain java components and therefore does not work properly
# in Japanese, Chinese or Korean locales on certain Linux
# distributions.
# A user can create "guijre" symlink in /etc/opt/SUNWut to
# point to appropriate JRE release that supports these locales.
# If set, this JRE will be used to launch utsettings GUI apps.
# 
if [[ -L $SUNWUTETC/guijre ]]
then
	SUNWUTJRE=$SUNWUTETC/guijre
else
	SUNWUTJRE=$SUNWUTETC/jre
fi

#
# Ignore any inherited JAVA_HOME, it could be pointing to any old
# garbage.  Use the JRE that was designated for use by Sun Ray, we
# know that it's of an acceptable vintage.
#
JAVA_HOME=$SUNWUTJRE
export JAVA_HOME

JAVA=$JAVA_HOME/bin/java

#
# 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

#
# Fire up the GUI, passing it any command line options we were given.
#
exec $JAVA $JAVADEFS SettingsGUI "$@"
