#!/usr/bin/qsh
# // THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM
# // 5724-I63, 5724-H88, 5655-N01, 5733-W61 (C) COPYRIGHT International Business Machines Corp., 1997, 2006
# // All Rights Reserved * Licensed Materials - Property of IBM
# // US Government Users Restricted Rights - Use, duplication or disclosure
# // restricted by GSA ADP Schedule Contract with IBM Corp.
#
# //  DESCRIPTION:
# //      Script file used to run the WebSphere
# //      Application Server administrative scripting tool.

. $(/usr/bin/dirname $0)/setupCmdLine

# Issue error message if we are unable to determine valid profile
CMD_NAME=`basename $0`

if [ "${INV_PRF_SPECIFIED:=}" != "" ] && [ "$INV_PRF_SPECIFIED" = "true" ]
then
    ${JAVA_HOME}/bin/java -cp "${WAS_HOME}/lib/commandlineutils.jar" com.ibm.ws.install.commandline.utils.CommandLineUtils -specifiedProfileNotExists -profileName $WAS_PROFILE_NAME
    exit 1
elif [ "${WAS_USER_SCRIPT_FILE_NOT_EXISTS:=}" != "" ] && [ "$WAS_USER_SCRIPT_FILE_NOT_EXISTS" = "true" ]
then
    ${JAVA_HOME}/bin/java -cp "${WAS_HOME}/lib/commandlineutils.jar" com.ibm.ws.install.commandline.utils.CommandLineUtils -wasUserScriptFileNotExists -wasUserScript $WAS_USER_SCRIPT
    exit 1
elif [ "${NO_DFT_PRF_EXISTS:=}" != "" ] && [ "$NO_DFT_PRF_EXISTS" = "true" ]
then
    ${JAVA_HOME}/bin/java -cp "${WAS_HOME}/lib/commandlineutils.jar" com.ibm.ws.install.commandline.utils.CommandLineUtils -noDefaultProfile -commandName $CMD_NAME
    exit 1
fi

if [ -z "$JAASSOAP" ]; then
  JAASSOAP="-Djaassoap=off"
fi

WAS_CLASSPATH=${WAS_CLASSPATH}:${ITP_LOC}/batchboot.jar:${ITP_LOC}/batch2.jar
set_conglomerates

isJavaOption=false
for option in "$@" ; do
  if [ "$option" = "-javaoption" ] ; then
     isJavaOption=true
  else
     if [ "$isJavaOption" = "true" ] ; then
        javaoption=$option
        break
     fi
  fi
done 

${JAVA_HOME}/bin/java ${JAVA_PARM} \
  -classpath ${WAS_CLASSPATH} \
  -Dlocal.cell=${WAS_CELL} \
  -Dlocal.node=${WAS_NODE} \
  -Dcom.ibm.etools.EJBDeploy.debug=true \
  -Dibm.websphere.preload.classes=true \
  -Dcom.ibm.itp.location=${ITP_LOC} \
  -Dwas.repository.root=${CONFIG_ROOT} \
  -Dcom.ibm.ws.scripting.wsadminprops=${WSADMIN_PROPERTIES} \
  -Dconfig_consistency_check=${CONFIG_CONSISTENCY_CHECK} \
  -Dcom.ibm.ws.management.standalone=true \
  -Dcom.ibm.CORBA.BootstrapHost=${COMPUTERNAME} \
  ${javaoption} \
  ${JAASSOAP} \
  ${WAS_LOGGING} \
  com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application \
  com.ibm.ws.bootstrap.WSLauncher \
  com.ibm.ws.admin.services.WsAdmin "$@"
