#!/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:

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

# Save the input parameters
INPUT_PARMS="$@"

################################################################
# Function called by the rearg_match_boolean_arg() below       #
# $1 is passed as either -delete or -deleteAll                 #
################################################################
chgown()
{
   TARGET_DIR=
   if [ $1 = "-delete" ] ; then
      TARGET_DIR=${USER_INSTALL_ROOT}
   elif [ $1 = "-deleteAll" ] ; then
      TARGET_DIR=${WAS_USERDATA_ROOT}/profiles
   fi

   if [ -d ${TARGET_DIR} ]; then
     chown -R QEJBSVR ${TARGET_DIR} 2> /dev/null 
     chmod -R 755 ${TARGET_DIR} 2> /dev/null
   fi
}

################################################################
# Function called by the .rearg script for all single -options #
# as it parses the $@ parameter/options list that was passed.  #
################################################################
rearg_match_boolean_arg()
{
  local matched=1
  case $1 in
    -delete)    chgown $1 ;;
    -deleteAll) chgown $1 ;;
    *)          matched=0  ;;
  esac
  return $matched
}

######################################################################
# Source the utility script that is used to parse the parameter list #
# passed to this script.                                             #
# It will call the two functions (defined above ):                   #
#  1. rearg_match_arg_with_value()                                   #
#  2. rearg_match_boolean_arg()                                      #
# To allow this script to process its parameters/options             #
######################################################################
. ${WAS_HOME}/bin/.rearg

# Restore the input parameters
set -- ${INPUT_PARMS}

JAVA_SECURITY_FILE=${WAS_INSTALL_ROOT}/profileTemplates/default/documents/properties/java.security

${JAVA_HOME}/bin/java ${JAVA_PARM} \
  -Dosgi.configuration.area=${WAS_INSTALL_ROOT}\/configuration \
  -DWAS_HOME=${WAS_INSTALL_ROOT} \
  -Dsecurity.overridePropertiesFile=true \
  -Djava.security.properties=${JAVA_SECURITY_FILE} \
  -Dos400.file.create.auth=RX \
  -Dos400.dir.create.auth=RX \
  com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application \
  com.ibm.ws.bootstrap.WSLauncher \
  com.ibm.ws.runtime.WsProfile ${REGISTRY_PARM} "$@"

