#!/bin/sh

# 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=BASEDIR/PRODUCT_DIR
JAVA_HOME=JDK_PATH
USING_JDK14=IAS7INSTALL

JSS_HOME=JSSHOME
NSS_HOME=NSSHOME
NSPR_HOME=NSPRHOME
JAXP_HOME=${AM_HOME}/lib
JAXB_HOME=${AM_HOME}/lib
SEC_HOME=${AM_HOME}/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:CONFIG_DIR
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

SEC_JARS=${SEC_HOME}/jce1_2_1.jar:${SEC_HOME}/sunjce_provider.jar:${SEC_HOME}/US_export_policy.jar:${SEC_HOME}/local_policy.jar:${SEC_HOME}/jakarta-log4j-1.2.6.jar:${SEC_HOME}/xmlsec.jar:${JAVA_HOME}/jre/lib/sunrsasign.jar

JAXB_JARS=${JAXB_HOME}/jaxb-api.jar:${JAXB_HOME}/jaxb-impl.jar:${JAXB_HOME}/jaxb-xjc.jar:${JAXB_HOME}/jaxb-libs.jr:${JAXB_HOME}/relaxngDatatype.jar:${JAXB_HOME}/namespace.jar:${JAXB_HOME}/jax-qname.jar:${JAXB_HOME}/xsdlib.jar

AM_CLASSPATH=${AM_DIRS}:${SDK_JARS}:${JSS_JAR}:${SERVLET_JARS}:${LOGGING_JARS}:${JAXP_JARS}:${JAXB_JARS}:${SEC_JARS}:${AM_HOME}/lib/mail.jar:${AM_HOME}/lib/activation.jar

if [ -z "$LD_LIBRARY_PATH" ] ; then
	LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}"
else
	LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}":$LD_LIBRARY_PATH
fi
  
if [ "$OS_ARCH" = "Linux" ]; then
	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${JAVA_HOME}/jre/lib/i386/native_threads
fi
  
export LD_LIBRARY_PATH

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

JAVA_VER=`${JAVA_HOME}/bin/java -version 2>&1 | awk -F'"' '{print $2}'`

case $JAVA_VER in
1.4.*)
  BOOTCLASSPATHOPTION=""
  ;;
*)
  BOOTCLASSPATHOPTION="-Xbootclasspath/a:${AM_HOME}/lib/jdk_logging.jar:${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/charsets.jar"
  ;;
esac

# Setup proper LD_LIBRARY_PATH if not already set
${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"java.util.logging.config.class=com.sun.identity.log.s1is.LogConfigReader" com.iplanet.am.admin.cli.Main "$@"
