#!/usr/bin/qsh
#
# //  DESCRIPTION:
# //      Script file used to show the activity log.

#720384 parse the args list to remove/backup the -instance option and its value so that it is not modified
#by setupCmdLine
total_args=$# # keep track of the initial argument total, because $# will become meaningless
              # if unmatched arguments are found
arg_num=0     # current index in the initial argument list
while [ $total_args -gt $arg_num ]; do # loop through the initial arguments
  if [ "$1" == "-instance" ]; then
    INSTANCE_VALUE="$2"
    num_args=2
  else
    # no match, add the current argument to the end of the argument list
    # this ensures the remaining arguments will be in the same order they were specified
    set -- "$@" "$1"
    num_args=1
  fi
  shift $num_args
  arg_num=$(($arg_num + $num_args))
done

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

#720384 add the -instance and its value back to the arg list
if [ -n "$INSTANCE_VALUE" ]; then
  set -- -instance "$INSTANCE_VALUE" "$@"
fi

WAS_HEADER="-Dlogviewer.custom.header=${WAS_HOME}/properties/WsHeader"
WAS_LEVELS="-Dlogviewer.custom.levels=${WAS_HOME}/properties/WsLevels.properties"
WAS_LOG_REPOSITORY="-Dlog.repository.root=${USER_INSTALL_ROOT}/logs"


${JAVA_HOME}/bin/java ${JAVA_PARM} \
  $WAS_LOG_REPOSITORY \
  $WAS_HEADER \
  $WAS_LEVELS \
  com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application \
  com.ibm.ws.bootstrap.WSLauncher \
  com.ibm.hpel.logging.LogViewer "$@"
