#!/usr/bin/qsh
#
# //  DESCRIPTION:
# //      

. $(/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 "$SI_PATH" ]; then
  echo "Environment variable SI_PATH is not defined. You need to run the setenv.sh command from the "
  echo "solution install common directory first. "
  exit 1
fi

CP=${WAS_CLASSPATH}:${WAS_HOME}/optionalLibraries/jython.jar:${SI_CLASSPATH}

USER_JAVA_OPTION=
IN_JAVA_OPTION=0
for arg in "$@" ; do
 if [ $IN_JAVA_OPTION -eq 1 ]; then
  USER_JAVA_OPTION=${USER_JAVA_OPTION}${arg}
  IN_JAVA_OPTION=0
 fi
 if [ "$arg"="-javaoption" ]; then
  IN_JAVA_OPTION=1
 fi
done

${JAVA_HOME}/bin/java ${JAVA_PARM}${USER_JAVA_OPTION} \
  -Dcom.ibm.ws.scripting.wsadminprops=${WSADMIN_PROPERTIES} \
  -classpath {$CP} \
  com.ibm.ws.bootstrap.WSLauncher \
  com.ibm.ws.management.touchpoint.tpru.RegisterTouchpoints "$@"
