#!/bin/ksh  -x

# Copyright  2004 Sun Microsystems, Inc. All rights reserved. 
# 
# Sun Microsystems, Inc. has intellectual property rights relating to
# technology embodied in the product that is described in this document.
# In particular, and without limitation, these intellectual property rights
# may include one or more of the U.S. patents listed at
# http://www.sun.com/patents and one or more additional patents or pending
# patent applications in the U.S. and in other countries.
# 
# U.S. Government Rights - Commercial software. Government users are subject
# to the Sun Microsystems, Inc. standard license agreement and applicable
# provisions of the FAR and its supplements.
# 
# Use is subject to license terms. 
# 
# This distribution may include materials developed by third parties. Sun,
# Sun Microsystems, the Sun logo, Java and Sun[tm] ONE are trademarks or
# registered trademarks of Sun Microsystems, Inc. in the U.S. and other
# countries. 
# 
# Copyright  2004 Sun Microsystems, Inc. Tous droits rservs. Sun
# Microsystems, Inc. dtient les droits de proprit intellectuels relatifs
#  la technologie incorpore dans le produit qui est dcrit dans ce document.
# En particulier, et ce sans limitation, ces droits de proprit
# intellectuelle peuvent inclure un ou plus des brevets amricains lists
#  l'adresse http://www.sun.com/patents et un ou les brevets supplmentaires
# ou les applications de brevet en attente aux Etats - Unis et dans les
# autres pays.
# 
# L'utilisation est soumise aux termes du contrat de licence.
# 
# Cette distribution peut comprendre des composants dvelopps par des
# tierces parties.
# 
# Sun, Sun Microsystems, le logo Sun, Java et Sun[tm] ONE sont des marques
# de fabrique ou des marques dposes de Sun Microsystems, Inc. aux
# Etats-Unis et dans d'autres pays.


AM_HOME=IS_INSTALL_BASEDIR/IS_PRODNAME
JAVA_HOME=/usr/j2se
JDK14=true
LOCAL_LOGGING=true

JSS_HOME=/
NSS_HOME=/
NSPR_HOME=/
JAXP_HOME=//usr/share/lib

JSS_JAR_PATH=TAG_JSS_JAR_PATH
JSS_SO_PATH=TAG_JSS_SO_PATH
NSPR_SO_PATH=TAG_NSPR_SO_PATH
NSS_SO_PATH=TAG_NSS_SO_PATH

JSS_JAR=${JSS_JAR_PATH}/jss3.jar

OS_ARCH=`/bin/uname -s`
SDK_JARS=${AM_HOME}/lib/am_sdk.jar:${AM_HOME}/lib/am_services.jar:${AM_HOME}/lib/jaas.jar
AM_DIRS=${AM_HOME}/lib:${AM_HOME}/locale:IS_INSTALL_ETCDIR/IS_PRODNAME/config
JAXP_JARS=${JAXP_HOME}/jaxp-api.jar:${JAXP_HOME}/xalan.jar:${JAXP_HOME}/xercesImpl.jar:${JAXP_HOME}/sax.jar:${JAXP_HOME}/dom.jar
SERVLET_JARS=${AM_HOME}/lib/servlet.jar:${AM_HOME}/lib/preference_servlet.jar
LOGGING_JARS=${AM_HOME}/lib/am_logging.jar

AM_CLASSPATH=.:${AM_DIRS}:${SDK_JARS}:${JSS_JAR}:${SERVLET_JARS}:${LOGGING_JARS}:${JAXP_JARS}

# Setup proper LD_LIBRARY_PATH if not already set
if [ -z "$LD_LIBRARY_PATH" ] ; then
    if [ $OS_ARCH = "Linux" ] ; then
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}:$JAVA_HOME/jre/lib/i386/native_threads"
    else
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}"
    fi
else
    if [ $OS_ARCH = "Linux" ] ; then
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}":$JAVA_HOME/jre/lib/i386/native_threads:$LD_LIBRARY_PATH
    else
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}":$LD_LIBRARY_PATH
    fi
fi

export LD_LIBRARY_PATH

if [ -z "$CLASSPATH" ]
then
  CLASSPATH="${AM_CLASSPATH}:${JAVA_HOME}/lib/lib.zip"
else
  CLASSPATH="${AM_CLASSPATH}:$CLASSPATH"
fi

if [ "$JDK14" = "true" ]; then
  BOOTCLASSPATHOPTION=""
else
  BOOTCLASSPATHOPTION="-Xbootclasspath:${AM_HOME}/lib/jdk_logging.jar:${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/i18n.jar"
fi

if [ "$LOCAL_LOGGING" = "true" ]; then
  CONFIGOPTION="java.util.logging.config.class=com.sun.identity.log.s1is.LogConfigReader"
else
  CONFIGOPTION="java.util.logging.config.file=${AM_HOME}/lib/LogConfig.properties"
fi

${JAVA_HOME}/bin/java  -Xms64m -Xmx256m ${BOOTCLASSPATHOPTION}  -classpath ${CLASSPATH} -D"max_conn_pool=10" -D"min_conn_pool=1" -D"java.protocol.handler.pkgs=com.iplanet.services.comm" -D"java.util.logging.manager=com.sun.identity.log.LogManager" -D${CONFIGOPTION} LogSample "$@"
