#!/bin/ksh
#
# ident "@(#)utmhconfig.sh	1.13 04/10/02 SMI"
#
# Copyright 2000,2002-2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

function usage {
	print -u2 "Usage: $prog"
	exit 1
}

SUNWUTLIB=$(/etc/opt/SUNWut/basedir/lib/utprodinfo -r SUNWuto)/SUNWut/lib
SUNWUTIMAGES="$SUNWUTLIB"/locale/images
SUNWUTETC=/etc/opt/SUNWut

#
# Purpose of the new symlink - guijre :
# Pre 1.5 JRE releases can not 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 utmhconfig 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 PATH
#
PATH=/usr/bin:/usr/sbin:/bin:/usr/openwin/bin:/usr/X11R6/bin

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

#
# Set LD_LIBRARY_PATH so Java knows where to get C libraries (native
# methods) from.
#
LD_LIBRARY_PATH=$SUNWUTLIB:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

prog=${0##*/}
while getopts ":" c
do
	case $c in
	\?)
		print -u2 "$prog: unknown option '$OPTARG'"
		usage;
		;;
	esac
done

shift `expr $OPTIND - 1`
if [ $# -ne 0 ]; then
	print -u2 "$prog: illegal argument(s) '$*'"
	usage
	exit 1
fi

if [[ -z "$DISPLAY" ]]; then
	print -u2 "$prog: DISPLAY environment variable must be set"
	usage
	exit 1
fi

env 	\
	CLASSPATH="$CLASSPATH:$LD_LIBRARY_PATH"	\
	$JAVA -DUTImageRoot="$SUNWUTIMAGES" admin.multihead.utmhconfig.MultiheadConfig
