#!/bin/ksh
##########################################################################
#IBM Confidential
#OCO Source Materials
#5747-SM3
#(c) Copyright IBM Corporation 1994, 2008
#The source code for this program is not published or otherwise divested
#of its trade secrets, irrespective of what has been deposited with
#the U.S. Copyright office.
##########################################################################
#  Copyright (c) 2005 Ascential Software Inc.
#
#  All rights reserved. You may not use, copy, modify or transfer this
#  program or any copy, modification or portion, in whole or in part,
#  without the explicit written permission of Ascential Software Ltd.
#
#############################################################################
#############################################################################
#  Change Log:
#
#  Date        Pgmr      Comments
#
#  mm/dd/yyyy            Version
#############################################################################
#############################################################################
# Description: Checks for a prior installed IBM WebSphere Process Server.
#############################################################################
function check_wesb_prereq
{
#
# Start with no brokers found
#
  typeset line=""
  typeset rc=0
  typeset -i pathindx
  
  set -A WPS_Installs
  WPS_Found="FALSE"
#
# The WebSphere Process Server installations are recorded within a registry.
# The process server folks say the registry is located at:
# /opt/.ibm/.nif/.nifregistry.
#
# Apparently, the information is not entirely correct. A function has been
# created to hide the locating of this file.
#
  find_nifregistry
#
# if an installation registry was located.
# 
  rc=$?
  if [[ ${rc} = 0 && -f ${nifreg} ]]; then
#
#   read through the registry looking for Process server installs.
#   The entries in the registry are located by the product id: WBI
#
    exec 5< ${nifreg} 
    while read -u5 line
    do
#
#     process server and WESB lines are considered
#
      rc=1
      print ${line} | grep "<product" | grep ${WPS_ID} > /dev/null 2>&1 
      rc=$?
      if [[ ${rc} != 0 ]]; then
        print ${line} | grep "<product" | grep ${WESB_ID} > /dev/null 2>&1
        rc=$?
      fi
#
#     if either process server or WESB found      
#      
      if [[ ${rc} = 0 ]]; then
#
#       a candidate line has been found. Isolate the install location 
#       and version.
#
        uri_path=""
        uri_version=""
        set ${line}
        for uri_seg in $@; do
#
#         installation path
#          
          if [[ "installrooturi${uri_seg#installrooturi}" = "${uri_seg}" ]]; then
            uri_path=${uri_seg#installrooturi=\"file:}
            uri_path=${uri_path%\"}
#
#           remove doubled path seperators
#
            rc=0
            while [[ ${rc} = 0 ]]; do
              print -r ${uri_path} | grep // > /dev/null 2>&1 
              rc=$?
              if [[ ${rc} = 0 ]]; then
                uri_path=$(print -r ${uri_path} | sed "s|//|/|g")
              fi 
            done            
#
            if [[ ! -d ${uri_path} ]]; then uri_path=""; fi
#            
          elif [[ "version${uri_seg#version}" = "${uri_seg}" ]]; then
#
#           Isolate the version specification. 
#          
            uri_version=${uri_seg#version=\"}
            uri_version=${uri_version%\"*}
#
#           if a minimum is provided, insure the detected version is
#           acceptable.
#
            if [[ ! -z ${MIN_ESB_VER} ]]; then
              compare_versions ${uri_version} ${MIN_ESB_VER}
              rc=$?
#
#             A non-zero return indicates the minimum version has 
#             not been met. 
#             
              if [[ ${rc} != 0 ]]; then
                uri_version=""
              fi  
            fi
          fi
        done
#
#       if a path and allowed version are found, record the location
#        
        if [[ ! -z ${uri_path} && ! -z ${uri_version} ]]; then
          if [[ "${uri_path%/}/" = "${uri_path}" ]]; then
            uri_path=${uri_path%/}
          fi
#
#         insure the located path is only used once
#
          if [[ ${#WPS_Installs[*]} != 0 ]]; then
            pathindx=0
            while [[ ${pathindx} -lt ${#WPS_Installs[*]} ]]; do
              if [[ "${uri_path}/plugins" = ${WPS_Installs[${pathindx}]} ]]; then
                uri_path=""
                break
              fi
              pathindx=$(( ${pathindx} + 1 ))
            done
          fi
#          
          if [[ ! -z ${uri_path} ]]; then
            WPS_Installs[${#WPS_Installs[*]}]="${uri_path}/plugins"
          fi
        fi
      fi
    done;
#
#   If any applicable product installations were recorded, report
#   the result.
#
    if [[ ${#WPS_Installs[*]} != 0 ]]; then
#
#     Mark that at least one process server installation was identified
#
      WPS_Found="TRUE"
      PresentMessage INFO_WPSDETECTED ${#WPS_Installs[*]}
    else
#
#     No process servers were located, record the result
#
      WPS_Found="FALSE"
    fi
  else
#
#   nif registry could not be found therefore, no installs were 
#   detected.
#
    WPS_Found="FALSE"
#
  fi  
}
#############################################################################
# Description: Compare product detected and minimum required version.
#############################################################################
function compare_versions
{
  typeset -i local_rc
  typeset -i ary_seg
  set -A act_ary
  set -A min_ary
  local_rc=0
  act_ver=${1}
  min_ver=${2}
#
# Both 
#
  if [[ ! -z ${act_ver} && ! -z ${min_ver} ]]; then
# 
#   split both product detected and minimum version strings
#   into segments for comparision. The version strings are assumed to 
#   be a period (".") delimited string of digits.
#
    old_ifs="${IFS}"
    IFS="."
    set ${act_ver}
    IFS="${old_ifs}"
    for ver_seg in $@; do
      act_ary[${#act_ary[*]}]=${ver_seg}
    done
#
    old_ifs="${IFS}"
    IFS="."
    set ${min_ver}
    IFS="${old_ifs}"
    for ver_seg in $@; do
      min_ary[${#min_ary[*]}]=${ver_seg}
    done    
#
#   Examine each version segment, comparing the detected version
#   to the provided minimum version. If the detected version segment is
#   greater than or equal to the minimum version segment, the segment
#   comparision is considered successful. Version string segments are 
#   of the form "V.R.M.F" and are processed left to right, with each
#   successive digit holding less comparison significance. 
#   
    ary_seg=0
    while [[ ${ary_seg} -lt ${#min_ary[*]} ]]; do
#
#     if no minimum is required of this segment, requirment is
#     met and matching is complete
#
      if [[ ${min_ary[${ary_seg}]} = "X" || \
            ${min_ary[${ary_seg}]} = "x" ]]; then
#
#       mark all segments processed
#
        ary_seg=${#min_ary[*]}
#
#     if the product version segment is not at least the minimum
#     version segement, the version comparison fails
#        
      elif [[ ${act_ary[${ary_seg}]} -lt ${min_ary[${ary_seg}]} ]]; then
#
#       mark version compare failure and all segments processed
#
        local_rc=1
        ary_seg=${#min_ary[*]}
#
#       otherwise, look at the next segement.
#      
      else
        ary_seg=$(( ${ary_seg} + 1 ))
      fi
    done
  else
#
#   Improper arguments is an automatic comparison failure
#
    local_rc=1
  fi
  return ${local_rc}
}
#############################################################################
# Description: Locates the install registry - .nifregistry
#############################################################################
function find_nifregistry
{

  typeset -i rc
  rc=1
#
# The WebSphere Process Server installations are recorded within a registry.
# The rules outlined for locating the registry are as follows:
# 1) A global location is examined. For AIX, the location is rooted at
#    /usr. For all other unix platforms, the location is rooted at /opt.
#    the location path used is .ibm/.nif/.nifregistry
#
# 2) If no global registry is found, a non-root users' home directory is 
#    examined. The location path used is .nif/.nifregistry
#
  if [[ ${ostype} = "AIX" ]]; then
    lcl_nifreg="/usr/.ibm/${nifreg}"
  else
    lcl_nifreg="/opt/.ibm/${nifreg}"
  fi
#
# If the global registry is not found, check in the non-root user's home
# directory. Note that this test will only be performed if the installing
# user is not the root user. 
#
  if [[ ! -f ${lcl_nifreg} ]]; then
#
#   if a non-root id is being used for the installation, look in the users'
#   home directory.
#
    if [[ -z ${IAMROOT} || ${IAMROOT} != "TRUE" ]]; then
      oldpath=$(pwd)
      cd ~ 1>/dev/null 2>&1
      if [[ $? = 0 ]]; then
        lcl_nifreg="$(pwd)/${nifreg}"       
      else
#
#       home location failure.
#
        PresentMessage ERR_CANTCDDIR "HOME"
        PresentMessage INFO_CHKPERMS
        if [[ ${bInteractive} = "FALSE" ]]; then
          get_out
        fi 
      fi
      cd ${oldpath}
    fi  
  fi
#
# Finally, check for the registry file
#
  if [[ -f ${lcl_nifreg} ]]; then
    nifreg="${lcl_nifreg}"
    rc=0
  else
#
#   nif registry could not be found
#  
    WPS_Found="FALSE"
    rc=1
#    PresentMessage ERR_NONIFREG ${lcl_nifreg}
#    PresentMessage ERR_SUPPORTINFO ${CompanyName}
#    do_fail
  fi
  return ${rc}
}  
#############################################################################
# Description: Checks for a prior installed IBM Message Broker.
#############################################################################
function check_wmqi_prereq
{
#
# Start with no brokers found
#
  WMB_Found="FALSE"
#
# look for indications of v6 Message broker. V6 Broker is assumed to be installed if 
# a v6 profiles directory exists.
#
  if [[ -d ${WBI_V6x_PROPATH} ]]; then
#
#   The V6 profile directory exists. Report the condition and continue.
#
    PresentMessage INFO_WSMBDETECTED ${WBI_V6x_PROPATH}
#
#   This release imposes an install time pre-requisite of MB 6.1 or above. 
#   indicating V6 has been installed.
#
    WMB_Found="TRUE"
    
  fi
#  
}
#############################################################################
# Description: Clears the console screen.
#############################################################################
function do_clear_screen
{
   if [ "$ostype" = "Windows_NT" ]; then
       cls
   else
      tput clear
   fi
}
###############################################################################
# Description: Wait for the user to acknowledge by pressing the Enter key
###############################################################################
function wait_for_enter
{
   if [[ ! -z ${bInteractive} && ${bInteractive} = "TRUE" ]]; then
     PresentMessage PROMPT_ENTTOCONTINUE
     read reply
   fi
}
###############################################################################
# Description: make_alias:
# Attempt to create an alias named for argument 1, based on the option colon
# separated list provided in argument 2.
###############################################################################
function make_alias {
  cmd_name=${1}
  cmd_alts=${2}
#
# look to see if the command already exists
#  
  whence ${cmd_name} > /dev/null 2>&1
  if [[ $? != 0 ]]; then
#
#   The command was not found. If a list of alternative commands
#   was provided, determine if the alternatives can be found.
#  
    if [[ ! -z ${cmd_alts} ]]; then
      oldifs=${IFS}
      IFS=":"
      set ${cmd_alts}
      IFS=${oldifs}
#
#     Check each provided alternative command. If the alternative command 
#     exists, it becomes the target of the alias.
#  

      for cmd_alternative in $*; do
        cmd_path=$(whence ${cmd_alternative})
        if [[ $? = 0 ]]; then
          break
        fi
      done
    else
#
#     since the command itself cannot be found, and no alternatives 
#     were provided, set the alias target to be the same as the 
#     command. This leaves the installer no worse off.
#
      cmd_path=${cmd_name}
      PresentMessage ERR_ALIASNOTDETERMINED ${cmd_name}
    fi
  else
#
#   the requested command exists. No need for an alias
#  
    cmd_path=""
  fi
#
# Create the alias, if a target was determined.
#
  if [[ ! -z ${cmd_path} ]]; then
    alias ${cmd_name}=${cmd_path}
  fi
}
###############################################################################
# Description: set up default values
###############################################################################
function set_defaults
{
   dtxinst_ver=$(grep INFO_INSTVERSION: ${msg_file})
   dtxinst_ver=${dtxinst_ver#INFO_INSTVERSION:}
   oap="IBM_WebSphere_Enterprise_Open_Adapter_Pack_Supplement"
   prodfile="DTX_Product_File"
   progname="DTXINST"
   prod_prefix="WSDTX"
   cdkey="CD_KEY"
   P_I_D="TXIS"
   comp_hide="shared javaplat"
#   
   WSDTXCS_INDX=0
   WSDTXTE_INDX=1
   WSDTXL_INDX=2
   WSDTXWEB_INDX=3
   WSDTXSAC_INDX=4
   WSDTXLA_INDX=5
   WSDTXLS_INDX=6
   WSDTXOL_INDX=7
   WSDTXSNMP_INDX=8
   WSDTXMB_INDX=9
   WSDTXIS_INDX=10
   WSDTXAPI_INDX=11
   WSDTXIFXX_INDX=12
#
   prods[${WSDTXCS_INDX}]="${prod_prefix}CS.${platsuf}"
   prods[${WSDTXTE_INDX}]="${prod_prefix}TE.${platsuf}"
   prods[${WSDTXL_INDX}]="${prod_prefix}L.${platsuf}"
   prods[${WSDTXWEB_INDX}]="${prod_prefix}WEB.${platsuf}"
   prods[${WSDTXSAC_INDX}]="${prod_prefix}SAC.${platsuf}"
   prods[${WSDTXLA_INDX}]="${prod_prefix}LA.${platsuf}"
   prods[${WSDTXLS_INDX}]="${prod_prefix}LS.${platsuf}"
   prods[${WSDTXOL_INDX}]="${prod_prefix}OL.${platsuf}"
   prods[${WSDTXSNMP_INDX}]="${prod_prefix}SNMP.${platsuf}"
   prods[${WSDTXMB_INDX}]="${prod_prefix}MB.${platsuf}"
   prods[${WSDTXIS_INDX}]="${prod_prefix}IS.${platsuf}"
   prods[${WSDTXAPI_INDX}]="${prod_prefix}API.${platsuf}"
#
   prod_desc[${WSDTXCS_INDX}]="IBM WebSphere Transformation Extender with Command Server"
   prod_desc[${WSDTXTE_INDX}]="IBM WebSphere Transformation Extender"
   prod_desc[${WSDTXL_INDX}]="IBM WebSphere Transformation Extender with Launcher"
   prod_desc[${WSDTXWEB_INDX}]="IBM WebSphere Transformation Extender Pack for Web Services"
   prod_desc[${WSDTXSAC_INDX}]="IBM WebSphere Transformation Extender Secure Adapter Collection"
   prod_desc[${WSDTXLA_INDX}]="IBM WebSphere Transformation Extender Launcher Agent"
   prod_desc[${WSDTXLS_INDX}]="IBM WebSphere Transformation Extender Launcher Studio"
   prod_desc[${WSDTXOL_INDX}]="IBM WebSphere Transformation Extender Online Library"
   prod_desc[${WSDTXSNMP_INDX}]="IBM WebSphere Transformation Extender SNMP Collection"
   prod_desc[${WSDTXMB_INDX}]="IBM WebSphere Transformation Extender for Message Broker"
   prod_desc[${WSDTXIS_INDX}]="IBM WebSphere Transformation Extender for Integration Servers"
   prod_desc[${WSDTXAPI_INDX}]="IBM WebSphere Transformation Extender for Application Programming"
#
   prod_instkey[${WSDTXCS_INDX}]="IBM_WebSphere_Transformation_Extender_with_Command_Server"
   prod_instkey[${WSDTXTE_INDX}]="IBM_WebSphere_Transformation_Extender"
   prod_instkey[${WSDTXL_INDX}]="IBM_WebSphere_Transformation_Extender_with_Launcher"
   prod_instkey[${WSDTXWEB_INDX}]="IBM_WebSphere_Transformation_Extender_Pack_for_Web_Services"
   prod_instkey[${WSDTXSAC_INDX}]="IBM_WebSphere_Transformation_Extender_Secure_Adapter_Collection"
   prod_instkey[${WSDTXLA_INDX}]="IBM_WebSphere_Transformation_Extender_Launcher_Agent"
   prod_instkey[${WSDTXLS_INDX}]="IBM_WebSphere_Transformation_Extender_Launcher_Studio"
   prod_instkey[${WSDTXOL_INDX}]="IBM_WebSphere_Transformation_Extender_Online_Library"
   prod_instkey[${WSDTXSNMP_INDX}]="IBM_WebSphere_Transformation_Extender_SNMP_Collection"
   prod_instkey[${WSDTXMB_INDX}]="IBM_WebSphere_Transformation_Extender_for_Message_Broker"
   prod_instkey[${WSDTXIS_INDX}]="IBM_WebSphere_Transformation_Extender_for_Integration_Servers"
   prod_instkey[${WSDTXAPI_INDX}]="IBM_WebSphere_Transformation_Extender_for_Application_Programming"
#
#  product types:
#  CORE - core product. Assumes clean installation directory.
#  DEPENDANT - dependant install. Must be applied to a core install
#  HYBRID - Can either be stand-alone or applied to a core install.
#
   prod_type[${WSDTXCS_INDX}]="CORE"
   prod_type[${WSDTXTE_INDX}]="CORE"
   prod_type[${WSDTXL_INDX}]="CORE"
   prod_type[${WSDTXWEB_INDX}]="DEPENDANT"
   prod_type[${WSDTXSAC_INDX}]="DEPENDANT"
   prod_type[${WSDTXLA_INDX}]="HYBRID"
   prod_type[${WSDTXLS_INDX}]="HYBRID"
   prod_type[${WSDTXOL_INDX}]="HYBRID"
   prod_type[${WSDTXSNMP_INDX}]="DEPENDANT"
   prod_type[${WSDTXMB_INDX}]="CORE"
   prod_type[${WSDTXIS_INDX}]="CORE"
   prod_type[${WSDTXAPI_INDX}]="CORE"
#
   prod_found[${WSDTXCS_INDX}]="FALSE"
   prod_found[${WSDTXTE_INDX}]="FALSE"
   prod_found[${WSDTXL_INDX}]="FALSE"
   prod_found[${WSDTXWEB_INDX}]="FALSE"
   prod_found[${WSDTXSAC_INDX}]="FALSE"
   prod_found[${WSDTXLA_INDX}]="FALSE"
   prod_found[${WSDTXLS_INDX}]="FALSE"
   prod_found[${WSDTXOL_INDX}]="FALSE"
   prod_found[${WSDTXSNMP_INDX}]="FALSE"
   prod_found[${WSDTXMB_INDX}]="FALSE"
   prod_found[${WSDTXIS_INDX}]="FALSE"
   prod_found[${WSDTXAPI_INDX}]="FALSE"
   prod_found[${WSDTXIFXX_INDX}]="FALSE"
#
   numprods=${#prods[*]}
#
#
   CompanyName="IBM Corporation"   
#   
   Init_promptresp
#
#  create necessary aliases
#
   make_alias uncompress gunzip:compress
#   
}
###############################################################################
# Description: to be removed as not needed as so as this is proved
###############################################################################
function do_key
{
   if [ ! -f "$locdir$cdkey" ]; then
      decry_file="$instfile"
      return
   fi
}
##############################################################################
# Description: Perform license validation and decryption
##############################################################################
function authorize
{
  do_clear_screen
  if [[ -x "$tmp_instdir"/txvallic ]]; then
    "$tmp_instdir"/txvallic "$instfile"
    return_code=$?
    if [ "$return_code" -ne 0 ];then
      PresentMessage ERR_BADAUTH ${return_code}
      get_out
    else
      do_clear_screen
    fi
  fi
}
###############################################################################
# Description: Determine if the passed characters are all numbers
###############################################################################
function isnum
{
   typeset -L1 l1
   typeset -i ok
   typeset num
   num=$1
   while [ ! -z "$num" ]; do
      l1=$num
      ok=0
      for a in 0 1 2 3 4 5 6 7 8 9; do
         if [ $l1 = $a ]; then
            ok=1
            break
         fi
      done
      if [ $ok -eq 0 ]; then
         return 1
      fi
      num="${num#?}"
   done
   if [ $ok -eq 0 ]; then
      return 1
   fi
}
#####################################################################
# Description: Verifies that the argument is a positive integer.
#####################################################################
function isvalidnum
{
   isnum $1
   if [ $? -gt 0 ]; then
      return 1
   fi

   if [ $1 -lt $2 -o $1 -gt $3 ]; then
      return 1
   fi
   return 0
}
##########################################################################
# Description: Pad a string to the specified length
#
# Note: This function replaces pr_col
##########################################################################
function pad_column
{
   typeset -i lenfld
   typeset -i i
   typeset -i max
   typeset str=""
   max=$1
   spc=$2
   shift 2
   fld=$@
   lenfld="${#fld}"
   i=$max-$lenfld
   while [ $i -gt 0 ]; do
     str="$str "
     i=$i-1
   done
   print "$str$spc"      # Note: this must be a print statement.
}
##########################################################################
# Description: Determine the maximum string length from a list of strings
##########################################################################
function max_len
{
   typeset -i mlen=0
   typeset -i max=0
   list=$@
   set $list
   for l in $list; do
      mlen="${#l}"
      if [ $mlen -gt $max ]; then
         max=$mlen
         mstr=$l
      fi
   done
   max_len_len=$mstr
   return $max
}
###############################################################################
# Description: Present and accept product installation selections
###############################################################################
function get_prod
{
  typeset pr1
  typeset tmp
  typeset -i i j k len ok
  typeset -i loop=1
  typeset -i tmpnum

  cd $locdir
  if [ $? -ne 0 ]; then
    PresentMessage ERR_BADCD ${locdir}
    do_fail
  fi
  tmp="$(ls)"
  for pr1 in $tmp; do
    i=0
    while [ $i -lt $numprods ]; do
      if [ "$pr1" = "${prods[$i]}" ]; then
        prno="$prno $i"
      fi
      i=$i+1
    done
  done
  if [ -z "$prno" ]; then
    PresentMessage ERR_CANTINSTBADPROD
    PresentMessage ERR_SUPPORTINFO ${CompanyName}
    do_fail
  fi
  set $prno
  k=$#-1
  if [ $# -eq 1 ]; then
    infofile=${prods[$1]}
    inst_type=${prod_type[$1]}
    instfile="${infofile%.*}"
    instfile="$instfile$osver.$platsuf"
  else
    while [ $loop -eq 1 ]; do
      i=0
      j=0
      PresentMessage INFO_PRODLIST
      PresentationDelay ${sleeptime_long}
      do_clear_screen
      PresentMessage PROMPT_PRODSLCT
      for i in $prno; do
        DisplayMessage ${MSG_INFO} "$j) ${prod_desc[$i]}"
        j=$j+1
      done
      PresentMessage INFO_ONETERM "\n"
      PromptInstall ${PRODSELECT}
      reply=${prompt_response}
      if [ -z "$reply" ]; then
        PresentMessage INFO_INVRESP
        if [[ ${bInteractive} = "FALSE" ]]; then
          PresentMessage ERR_BADSELREC
          get_out
        fi
        PresentationDelay ${sleeptime_long}
        continue
      fi
      isnum $reply
      if [[ $? -gt 0 ]]; then
        PresentMessage INFO_INVRESP
        if [[ ${bInteractive} = "FALSE" ]]; then
          PresentMessage ERR_BADSELREC
          get_out
        fi
        PresentationDelay ${sleeptime_long}
        continue
      fi
#      
      if [[ "$reply" -gt $k || "$reply" -lt 0 ]]; then
        PresentMessage INFO_INVRESP
        if [[ ${bInteractive} = "FALSE" ]]; then
          PresentMessage ERR_BADSELREC
          get_out
        fi
        PresentationDelay ${sleeptime_long}
        continue
      fi
      loop=0
      case $reply in
        0)   i=$1
             ;;
        1)   i=$2
             ;;
        2)   i=$3
             ;;
        3)   i=$4
             ;;
        4)   i=$5
             ;;
        5)   i=$6
             ;;
        6)   i=$7
             ;;
        7)   i=$8
             ;;
        8)   i=$9
             ;;
        9)   i=$10
             ;;
        10)  i=$11
             ;;
         *)  loop=1
             continue
             ;;
      esac
      infofile=${prods[$i]}
      instfile="${infofile%.*}"
      instfile="$instfile$osver.$platsuf"
    done
  fi
  ok=0
  if [ -f "$locdir""$instfile" ]; then
    ok=1
  else
    tmpnum=$osver
    while [ "$tmpnum" -ge "$minver" ]; do
      instfile="${infofile%.*}"
      instfile="$instfile$tmpnum.$platsuf"
      if [ -f "$locdir""$instfile" ]; then
        ok=1
        break
      fi
      tmpnum=$tmpnum-1
    done
  fi
  cd - >> "$NUL"
  if [ $ok -eq 0 ]; then
    PresentMessage ERR_FNF ${instfile}
    PresentMessage ERR_SUPPORTINFO ${CompanyName}
    do_fail
  fi  
}
########################################################################
# Description: check for the existance of the specified directory
########################################################################
function chk_dir
{
   typeset -i local_rc
   typeset dir
   local_rc=1
   dir="${1##*:}"
   one_char=$dir
   if [ "$one_char" = "~" ]; then
     homedir="${HOME}"
     if [ ! -z "$homedir" ];then
       if [[ -d ${homedir} ]]; then 
         local_rc=0
       fi
     else
       cd  2>> "$ERR"
       homedir="${pwd}"
       if [[ ! -z ${homedir} ]]; then
         if [[ -d ${homedir} ]]; then 
           local_rc=0
         fi
       fi
       cd - 2>> "$ERR" 
     fi  
#       
     if [[ ${local_rc} != 0 ]]; then
       PresentMessage ERR_NOHOME
       get_out
     else
       dir="${dir#*/}"
       dir="${homedir}/${dir}"
     fi
   elif [ "$one_char" != "/" ]; then
     dir="$PWD/$dir"
   fi
#
   if [ -z "$dir" ]; then
      dir="."
   fi
   if [ ! -d "$dir" ]; then
      PresentMessage ERR_NOTDIR ${dir}
      chk_dir_dir=$PWD
      return 1
   fi
   if [ "$dir" = "." -o "$dir" = "./" ]; then
      dir="${PWD##*:}"
   fi
#
   one_char=$dir
   if [ "$one_char" != "/" ]; then
      chk_dir_dir=$PWD/$dir
   else
      chk_dir_dir="$dir"
   fi
   if [[ -d ${chk_dir_dir} ]]; then
     local_rc=0
   else
     local_rc=1
   fi
   return ${local_rc}
}
###############################################################################
# Description: Determine if arg1 exists at the beginning of arg2 (I think)
###############################################################################
function find_first
{
   if [[ $2 = $1* ]]; then
      return 0
   else
      return 1
   fi
}
###############################################################################
# Description: Determine if arg1 exists at the end of arg2 (I think)
###############################################################################
function find_last
{
   if [[ $2 = *$1 ]]; then
      return 0
   else
      return 1
   fi
}
###############################################################################
# Description: Determine if arg1 exists within arg2 (I think)
###############################################################################
function find_any
{
   if [[ $2 = *$1* ]]; then
      return 0
   else
      return 1
   fi
}
###############################################################################
# Description: Displays installation failure message and exits from setup 
#              procedure.
###############################################################################
function do_fail
{
   PresentMessage INFO_BADINST
   got_error=1
   inst_returncode=100
   get_out
}
###############################################################################
# Description: Used to provide immediate exit from the setup procedure. If 
#              given an error code it can display/send diagnostic information.
###############################################################################
function get_out
{
   if [ "$got_error" -eq 1 ]; then
      if [ -d "$tmp_instdir" ]; then
         print "Dir listing of $tmp_instdir" >> $ERR
         ls -alR $tmp_instdir >> $ERR
         print " " >> $ERR
      fi
      if [ -d "$installdir" ]; then
         print "Dir listing of $installdir" >> $ERR
         ls -alR $installdir >> $ERR
      fi
      if [ -f "$error_log" ]; then
         mv "$error_log"  $work_dir 2>> "$NUL"
         PresentMessage INFO_ERRLOGNAME ${work_dir}/${pgmname}.err.
      fi
   fi
   ERR=$NUL
   clr_tmpdir
   if [[ ! -z ${inst_returncode} ]]; then
     exit ${inst_returncode}
   else
     exit
   fi
}
###############################################################################
# Description: Deletes all files within the specified temporary directory.
###############################################################################
function clr_tmpdir
{
   if [ ! -z "$tmp_instdir" -a -d "$tmp_instdir" ]; then
      if [ ! -z "$curdir" ]; then
         cd "$curdir" 2>>"$NUL"
         rm -rf "$tmp_instdir" 2>> "$NUL"
      fi
   fi
}
###############################################################################
# Description: Check for potentially duplicate components. Duplicate components
#              are (apparently) removed before reinstallation.
###############################################################################
function chk_dup_comp
{
   typeset -i first_time
   typeset -i numdup
   typeset -i n
   typeset -i nn
   typeset -i removedboracle=0
   typeset -i removemqseries=0
   typeset -i removejavaapi=0
   numdup=0
   first_time=1
   dupcomp=${component%%_*}
   if [ "$dupcomp" = "dboracle8" ];then
        dupcomp=${component%8*}
   elif (( hp10 == 1 )) && [ "$dupcomp" = "m4mqsc" ];then
        dupcomp=${component%C*} 
   elif [ "$dupcomp" = "javaapi1.x" ] || [ "$dupcomp" = "javaapi1.y" ];then
        dupcomp=${component%%.*} 
   fi
   dupfiles="$(ls $sysdir/$dupcomp* 2>> "$ERR")"  
   if [ ! -z "$dupfiles" ]; then
      set $dupfiles
      while [ $# -gt 0 ]; do
         dup="${1##/*/}"
         shift
         find_first $dupcomp ${dup%%_*}
         if [ $? -eq 0 ]; then
            find_last ".uninstall" $dup
            if [ $? -eq 0 ]; then
               continue
            else
               dupf[numdup]="$(head -n1 "$sysdir/$dup" 2>> "$ERR")"
               dupf[numdup+1]="$sysdir/$dup"
               numdup=$numdup+2
#
#              save configuration for well recognized components.
#              Note: These components were known to contain configuration
#              files in the bluehawk release.
#
               if [[ ${dupcomp} = "shared" || ${dupcomp} = "configfiles" || ${dupcomp} = "dstxwmqi" ]]; then
                 SaveConfiguration
               fi               
            fi
         fi
      done
      if [ "$numdup" -gt 0 ]; then
         n=0
         while [ "$n" -lt "$numdup" ]; do
         if [[ ${printflag} != 1 ]]; then
   	    PresentMessage INFO_DUPCOMP ${dupf[$nn]}
            PresentMessage INFO_REMOVING ${dupf[$nn]}
         fi   
#
         comp_uninstall_script="${dupf[$nn+1]}.uninstall"
         if [[ -x ${comp_uninstall_script} ]]; then
           ${comp_uninstall_script} 2>> ${ERR}
         else
           PresentMessage WARN_REMCOMPSCRIPT ${dupf[$nn]}
         fi
#
         n=$n+2
       done
     fi
   fi
   return 1
}
###############################################################################
# Description: implements "pushd" command 
###############################################################################
function pushd
{
   typeset dirname
   dirname=$1
   if [ -d "$dirname" ]; then
      "cd" "$dirname" 2>>"$ERR"
      if [ $? -eq 0 ]; then
          DIRSTACK="$dirname ${DIRSTACK:-$PWD}"
      else
          return 1
      fi
   else
      return 1
   fi
   return 0
}
#############################################################################
# Description: implements "popd" command
#############################################################################
function popd
{
   if [ ! -z "$DIRSTACK" ]; then
       DIRSTACK=${DIRSTACK#* }
       "cd" ${DIRSTACK%% *} 2>>"$ERR"
       if [ $? -eq 0 ]; then
          return 0
       else
          return 1
       fi
   else
       return 1
   fi
   return 0
}
###############################################################################
# Description: Determine installation system working directory
###############################################################################
function get_sysdir
{
  if [[ ! -z ${installdir} ]]; then
    sysdir="$installdir/dtx_install"
    if [ -f "$sysdir" ]; then
      PresentMessage ERR_DIRISFILE ${sysdir}
      do_fail
    else
      if [ ! -d "$sysdir" ]; then
        tmp="$(mkdir "$sysdir" 2>>"$ERR")"
        if [ ! -z "$tmp" ]; then
          PresentMessage ERR_BADSYSCREATE ${sysdir}
          PresentMessage INFO_INSTTERM
          do_fail
        else
          if [ ! -z "$user" -a ! -z "$group" ]; then
            chown "$user:$group" "$sysdir" 2>>"$ERR"
          fi
        fi
      fi  
      chmod 755 "$sysdir" 2>>"$ERR"
    fi
  else
    PresentMessage ERR_NOINSTDIR ${installdir}
    do_fail
  fi
}
###############################################################################
# Description: Prompts the user to select a target directory. It will also
# check the selected directory for previously installed IBM WebSphere DTX
# products. The user will be given the chance to select a different
# directory if IBM WebSphere DTX already exists in that directory.
#
# Note: This is apparently the path for core installs that expect a fresh 
#       installation directory
###############################################################################
function get_installdir
{
   typeset -i return_code
   doyesno=0
   insdirok=0
   default=${prompt_resp[${TXINSTALLDIR}]}
   while [ $insdirok -eq 0 ]; do
#
     if [ -z "$installdir" ]; then
       doyesno=1
       if [[ ${inst_type} = "DEPENDANT" ]]; then
        PresentMessage PROMPT_UPDATEDIR ${default}
       else
        PresentMessage PROMPT_INSTDIR ${default}
       fi
#       
       PromptInstall ${TXINSTALLDIR}
       if [[ ! -z ${prompt_response} ]]; then
         installdir=${prompt_response}
       fi
     fi
#
     if [ -z "$installdir" ]; then
       if [[ ${bInteractive} = "FALSE" ]]; then
        PresentMessage ERR_INVRECINSDIR installation
         get_out
       else      
         installdir="${default}"         
       fi          
       continue
     fi
#
     chk_dir $installdir
     return_code=$?
     if [[ ${return_code} -gt 0 && ${inst_type} = "DEPENDANT" ]]; then
      PresentMessage ERR_INVDEPINSDIR
       if [[ ${bInteractive} = "FALSE" ]]; then
        PresentMessage ERR_INVRECINSDIR installation
         get_out
       fi           
       installdir=""
       insdirok=0
       continue
     fi
     installdir=$chk_dir_dir
#
      if [ $doyesno -eq 1 ]; then
      yes_no 1 PROMPT_INSTDIROK $installdir
	tmp=$?
      else
	tmp=1	
      fi
#
      if [ $tmp -eq 1 ]; then
         tmp="$(ls $installdir/dtx_install/IBM_WebSphere_* 2>> $ERR)"
         if [ -z "$tmp" ]; then
           PresentMessage ERR_INVTXDIR ${installdir}
           if [[ ${bInteractive} = "FALSE" ]]; then
           PresentMessage ERR_INVRECINSDIR installation
             get_out
           fi           
           installdir=""
           insdirok=0
           continue
         fi
         for tmp1 in $tmp; do
            prodinfo="$(head -n 3 $tmp1 2>> "$ERR")"
            set $prodinfo
            if [ "$1" = "DTX_Product_File" ]; then
               if [ "$6" != "IBM_WebSphere_Enterprise_Open_Adapter_Pack_Supplement" ]; then
                  oprod_file=$tmp1
                  product_name1="${tmp1##*/}"
                  if [ $6 = "$product_name1" ]; then
                     oproduct_ostype=$3
                     oproduct_osver=$4
                     oproduct_ver1=$7
                     oproduct_ver="${7%%\(*}"
                     shift;shift;shift;shift;shift
                     oproduct_namex=$1
                     shift;shift
                     oproduct_name=$@
                  fi
                  break
               fi
            fi
         done
         if [ -z "$product_name" ]; then
           PresentMessage ERR_INVTXDIR ${installdir}
           if [[ ${bInteractive} = "FALSE" ]]; then
             PresentMessage ERR_INVRECINSDIR installation
             get_out
           fi                       
           continue
         fi
      else
        installdir=""
        insdirok=0     
      fi
      insdirok=1
   done
   sysdir="$installdir/dtx_install"
   if [ ! -d "$sysdir" ]; then
      PresentMessage ERR_NOTFOUND $sysdir
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail

   fi
   if [ "$info_prod" = "$oap" ]; then
      tmp="$(ls -ld "$sysdir" 2>> "$ERR")"
      op_id="$(id | cut -f1 -d' ' | fgrep root)"
      #op_id="$(id | fgrep root)"
      if [ -z "$op_id" ]; then
         set $tmp
         if [ ! -O "$sysdir" ]; then
            PresentMessage ERR_NOTOWNER $sysdir
            get_out
         fi
         if [ 0 -eq 1 ]; then
            if [ ! -G "$sysdir" ]; then
               PresentMessage ERR_NOTGROUPOWNER $sysdir
               get_out
            fi
         fi
      fi
   fi
   yes_no 1 PROMPT_PRODINSTALLED $product_name
   if [ $? -eq 0 ]; then
      return 1
   else
      return 0
   fi
}
###############################################################################
# Description: Used to prompt the user in the event that an existing file may
#              be overwriten.
###############################################################################
function chk_file
{
   if [ -f "$1" ]; then
      yes_no 1 PROMPT_OVERWRITEFILE $1
      return $?
   fi
   return 1
}
###############################################################################
# Description: Detects installation platform environment.
###############################################################################
function get_os_version
{
  case $ostype in
  "SunOS")
    inst_libpathname=LD_LIBRARY_PATH
    tmp="$(uname -a)"
    set $tmp
    tmp=$3
    oldifs=$IFS
    IFS="."
    set $tmp
    IFS=$oldifs
    platsuf="SUN"
    if [ "$1" = "5" ]; then
      platver="2"
      platverm="$2"
      osver="$platver$platverm"
    else
      PresentMessage ERR_INVPLATVER SunOS $platver
      PresentMessage INFO_ALLTERMS "$(uname -a)"
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    fi
    minver="27"
    sosl="so"
    ;;
#
  "Linux")
    inst_libpathname=LD_LIBRARY_PATH
    tmp="$(uname -a)"
    set $tmp
    tmp=$3
    oldifs=$IFS
    IFS="."
    set $tmp
    IFS=$oldifs
    platver=$1
    platverm=$2
    platsuf="LINUX"
#                     
    if [[ ${platver} -lt 2 ]]; then
      PresentMessage ERR_INVKERNAL ${platver}
      PresentMessage INFO_ALLTERMS "$(uname -a)"
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    fi
    osver="$platver$platverm"                     
    minver="24"
    sosl="so"
    ;;
#
  "zLinux")
    inst_libpathname=LD_LIBRARY_PATH
    tmp="$(uname -a)"
    set $tmp
    tmp=$3
    oldifs=$IFS
    IFS="."
    set $tmp
    IFS=$oldifs
    platver=$1
    platverm=$2
    platsuf="ZLINUX"
#                     
    if [[ ${platver} -lt 2 ]]; then
      PresentMessage ERR_INVKERNAL ${platver}
      PresentMessage INFO_ALLTERMS "$(uname -a)"
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    fi
    osver="$platver$platverm"                     
    minver="26"
    sosl="so"
    ;;
#
  "AIX")
    inst_libpathname=LIBPATH
    tmp="$(uname -a)"
    set $tmp
    platsuf="AIX"
    platver="$4"
    platverm="$3"
    osver="$platver$platverm"
    minver="51"
    sosl="so"
    ;;
  "HP-UX")
    inst_libpathname=SHLIB_PATH
    tmp="$(uname -a)"
    set $tmp
    tmp=$3
    oldifs=$IFS
    IFS="."
    set $tmp
    IFS=$oldifs
    osver="$2"
    platsuf="HP"
    platver="$osver"
    minver="11"
    sosl="sl"
    ;;
  "ITANIUM")
    inst_libpathname=SHLIB_PATH
    tmp="$(uname -a)"
    set $tmp
    tmp=$3
    oldifs=$IFS
    IFS="."
    set $tmp
    IFS=$oldifs
    osver="$2"
    platsuf="HP"
    platver="$osver"
    minver="11"
    sosl="so"
    ;;
  "OSF1")
    tmp="$(uname -a)"
    set $tmp
    tmp=$3
    oldifs=$IFS
    IFS="."
    set $tmp
    IFS=$oldifs
    tmp="$1"
    one_char="$tmp"
    tmp=${tmp#?}
    osver=$tmp
    platsuf="DEC"
    platver="$osver"
    minver="4"
    sosl="so"
    ;;
  "Windows_NT")
    osver="$(uname -r)"
    platsuf="NT"
    platver="4"
    sosl="dll"
    ;;
  *)
    PresentMessage ERR_INVOSVER ${ostype}
    PresentMessage ERR_SUPPORTINFO ${CompanyName}
    do_fail
    ;;
  esac
}
###############################################################################
# Description: Used to prompt the user to specify the user and group that will
#              be given ownership of the installation following an install 
#              by root.
###############################################################################
function get_user
{
  userm=root
  tmp="$(ls -ld "$tmp_instdir" 2>> "$ERR")"
  set $tmp
  userm=$3
  if [[ -z ${userm} ]]; then
    PresentMessage ERR_BADWHOUSER
    userm=$(id)
    tmp_userm=${userm#uid=*\)}
    userm=${userm%${tmp_userm}*}
    userm=${userm#uid=*\(}
    userm=${userm%\)}
    if [[ -z ${userm} ]]; then 
      PresentMessage ERR_BADWHO
      userm="root"
    else
      PresentMessage INFO_WHO ${userm} 
    fi
  fi
  if [ "$userm" = "root" ]; then
    IAMROOT=TRUE
    loop=1
    while [ "$loop" = 1 ]; do
      user=""
      group=""
      while [[ -z ${user} ]]; do
        PresentMessage PROMPT_WHOOWN
        PromptInstall ${TXOWNUSER}
        user=${prompt_response}
        if [[ ${bInteractive} = "FALSE" && -z ${user} ]]; then
          PresentMessage ERR_RECSPECERR User 
          get_out
        fi
      done
      while [[ -z ${group} ]]; do
        PresentMessage PROMPT_WHOGRP
        PromptInstall ${TXOWNGROUP}
        group=${prompt_response}
        if [[ ${bInteractive} = "FALSE" && -z ${group} ]]; then
          PresentMessage ERR_RECSPECERR Group
          get_out
        fi
      done
      touch "$tmp_instdir/tmpfile"
      if [ ! -z "$user" -a ! -z "$group" ]; then
        tmp="$(chown "$user:$group" "$tmp_instdir/tmpfile" 2>>"$ERR")"
      fi
      tmp="$(ls -l "$tmp_instdir/tmpfile" | grep "$user" 2>>"$ERR")"
      if [ ! -z "$tmp" ]; then
        tmp="$(ls -l "$tmp_instdir/tmpfile" | grep "$group" 2>>"$ERR")"
        if [ ! -z "$tmp" ]; then
          loop=0
        else
          if [[ ${bInteractive} = "FALSE" && -z ${group} ]]; then
            PresentMessage ERR_RECSPECERR Group
            get_out
          fi
          PresentMessage ERR_BADGRP $group
        fi
      else
        if [[ ${bInteractive} = "FALSE" && -z ${group} ]]; then
          PresentMessage ERR_RECSPECERR User or Group
          get_out
        fi
        PresentMessage ERR_NOWHO $user $group 
      fi
    done
    userm=$user
  fi
}
###############################################################################
# Description: Provides user feedback on the success or failure of component
#              installation.
#
# Note: This function is in need of simplification
###############################################################################
function tell_about
{
   if [ $1 -eq 1 ]; then
      tmp="$(date 2>>"$ERR")"
      print "$compdesc" > "$sysdir/$component"
      if [ ! -z "$user" -a ! -z "$group" ]; then
         tmp="$(chown "$user:$group" "$sysdir/$component" 2>>"$ERR")"
      fi
      print "Installed: $tmp" >> "$sysdir/$component"
      cat "$compfile" >> "$sysdir/$component"
      PresentMessage INFO_INSRECCP $sysdir/$component
      install_good=$install_good+1
      tmp="$(date 2>>"$ERR")"
      PresentMessage INFO_INSSUCCESS $compdesc
      #For files created by installs
      if [ "$component" = "shared" -o "$component" = "sharedINT" ];then
      	      print "Remove  $installdir/libs/install.properties 2>>$NUL" >> "$uninstall"
      	      print "Remove  $installdir/setup 2>>$NUL" 		  >> "$uninstall"		
      fi
      print "rm -f $sysdir/$component 2>>$NUL" >> "$uninstall"
      print "rm -f $uninstall 2>>$NUL" >> "$uninstall"
      if [ "$info_prod" != "$oap" ]; then
         print "print \" $component \($compdesc\) uninstalled: "'$(date)' \" ">> $status" >> "$uninstall"
      fi
   else
      if [ 0 -eq 1 ]; then
         cp -fpp "$compfile" "$sysdir/$component"
         if [ ! -z "$user" -a ! -z "$group" ]; then
            tmp="$(chown "$user:$group" "$sysdir/$component" 2>>"$ERR")"
         fi
         PresentMessage INFO_INSRECCP $sysdir/$component
         tmp="$(date 2>>"$ERR")"
         print "INSTALL_DATE  $tmp" "<<< FAILED >>>" >> "$sysdir/$component"
      fi
      install_fail=$install_fail+1
      PresentMessage INFO_INSFAIL $compdesc
      print "rm -f $sysdir/$component 2>>$NUL" >> "$uninstall"
      print "rm -f $uninstall 2>>$NUL" >> "$uninstall"
      "$uninstall" 2>> "$NUL"
      PresentationDelay ${sleeptime_long}
   fi
}
###############################################################################
# Description: Capture forced exits from the setup procedure in the event of
#              process signals (kill).
###############################################################################
function terminate
{
   PresentMessage INFO_USERTERM
   get_out
}
###############################################################################
# Description: Determine the current effective user id
###############################################################################
function find_user
{
# ###########################################################
# ## If whoami is available, use it. Otherwise, try creating
# ## a temporary file and capture the owner. If all else
# ## fails, use who.
# ###########################################################
  current_user=""
  whence whoami > /dev/null 2>&1
  if [[ $? = 0 ]]; then
#
#   use whoami
#
    current_user=$(whoami 2>>${ERR})
  else
#
#   whoami could not be found. Try creating a temp file
#   to determine ownership.
#
    
    touch ${tmp_instdir}/testuserid.tmp
    if [[ -f ${tmp_instdir}/testuserid.tmp ]]; then
      current_user=$(ls -ld ${tmp_instdir}/testuserid.tmp 2>> ${ERR})
      current_user=$(echo ${current_user} | cut -f 3 -d ' ')
      rm -f ${tmp_instdir}/testuserid.tmp
    fi
  fi
#
# if no user id was determined, use who
#
  if [[ -z ${current_user} || ${current_user} = "" ]]; then
    current_user=$(who -m | cut -d ' ' -f 1 2>>${ERR})
  fi
#
  if [[ ${current_user} = "root" ]]; then
        current_user=${user}
    return 1
  else
    return 0
  fi
}
###############################################################################
# Description: Prompts the user to select a target directory. It will also
#              check the selected directory for previously installed IBM WebSphere 
#              products. The user will be given the chance to select a different
#              directory if IBM WebSphere DTX already exists in that directory.
###############################################################################
function mk_installdir
{
  doyesno=0
  insdirok=0
  default=${prompt_resp[${TXINSTALLDIR}]}
#
  while [ $insdirok -eq 0 ]; do
    if [ -z "$installdir" ]; then
      doyesno=1
      if [[ ${inst_type} = "DEPENDANT" ]]; then
        PresentMessage PROMPT_UPDATEDIR ${default}
      else
        PresentMessage PROMPT_INSTDIR ${default}
      fi
      PromptInstall ${TXINSTALLDIR}
      if [[ ! -z ${prompt_response} ]]; then
        installdir=${prompt_response}
      fi
    fi	
#
    if [ -z "$installdir" ]; then
      if [[ ${bInteractive} = "FALSE" ]]; then
        PresentMessage ERR_INVRECINSDIR installation
        get_out
      else      
        installdir="${default}"
      fi 
    else
      one_char=$installdir
      if [ "$one_char" = "~" ]; then
        homedir="${HOME}"
        if [ -z "$homedir" ];then
          cd  2>> "$ERR"
          homedir="${pwd}"
          cd - > "$ERR" 2>&1
          if [ $? -gt 0 ];then
            if [[ ${bInteractive} = "FALSE" ]]; then
              PresentMessage ERR_INVRECINSDIR installation
            else
              PresentMessage ERR_NOHOME 
            fi
            do_fail
          fi
        fi            	
        installdir="${installdir#*/}"
        installdir="${homedir}/${installdir}"            
      elif [ "$one_char" != "/" ]; then
        installdir="$curdir/$installdir"
      fi         
    fi
#    
    if [ $doyesno -eq 1 ]; then
      yes_no 1 PROMPT_INSTDIROK $installdir
      tmp=$?
    else
      tmp=1	
    fi
#
    if [ $tmp -eq 1 ]; then
      if [ ! -d "$installdir" ]; then
        if [[ ${inst_type} = "DEPENDANT" ]]; then
          PresentMessage ERR_MISSINGDIR ${installdir}
          if [[ ${bInteractive} = "FALSE" ]]; then
            get_out
          fi 
          PresentationDelay ${sleeptime_long}
          installdir=""
          insdirok=0
        else
          if [ ! -f "$installdir" ]; then
            PresentMessage INFO_CREATEINSDIR installation $installdir
            tmp="$(mkdir "$installdir" 2>>"$ERR")"
            if [ ! -d "$installdir" ]; then
              PresentMessage ERR_CANTCREATEINSTDIR installation ${installdir}
              PresentMessage INFO_CHKPERMS
              if [[ ${bInteractive} = "FALSE" ]]; then
                get_out
              else
                installdir=""
                insdirok=0
              fi      
            else
              insdirok=1
              if [ ! -z "$user" -a ! -z "$group" ]; then
                chown $user:$group "$installdir" 2>> "$ERR"
              fi
              chmod 775 "$installdir" 2>> "$ERR"
              if [ $? -gt 0 ]; then
                PresentMessage ERR_CANTCHMODINSTDIR ${installdir}
                PresentMessage INFO_CHKPERMS
                if [[ ${bInteractive} = "FALSE" ]]; then
                  get_out
                fi 
                installdir=""
                insdirok=0
              fi
            PresentationDelay ${sleeptime_long}
            fi
          else
            PresentMessage ERR_CANTCREATEDIR_FILE
            if [[ ${bInteractive} = "FALSE" ]]; then
              get_out
            else
              installdir=""
              insdirok=0
            fi      
          fi
        fi  
      else
        insdirok=1
      fi
    else
      installdir=""
      insdirok=0
    fi
  done
  if [ ! -z "$user" -a ! -z "$group" ]; then      
    chmod 775 "$installdir"
    tmp="$(chown "$user:$group" "$installdir" 2>>"$ERR")"
  fi
}
###############################################################################
# Description: prompt for and create the installation work area directory
#
# Note: This function should be simplified
###############################################################################
function mk_tmp_instdir
{
   cur_workdir=$curdir
   loop=1
   work_dir=""
   default=${prompt_resp[${TXTMPDIR}]}
   while [ "$loop" = 1 ]; do
      PresentMessage PROMPT_WORKDIR
      PresentMessage PROMPT_ACCPTDEFDIR ${default}
      PresentMessage INFO_SUBINWORK
      PromptInstall ${TXTMPDIR}
      if [[ ! -z ${prompt_response} ]]; then
        work_dir=${prompt_response}
      fi
#
      if [ -z "$work_dir" ]; then
         work_dir="$default"
      else
         one_char=$work_dir
         if [ "$one_char" != "/" ]; then
            work_dir="$curdir/$work_dir"
         fi
      fi
      if [ ! -d "$work_dir" ]; then
         PresentMessage ERR_NOTDIR $work_dir
         if [[ ${bInteractive} = "FALSE" ]]; then
           PresentMessage ERR_INVRECINSDIR working 
           get_out
         fi              
         continue
      fi
      yes_no 1 PROMPT_WORKDIROK $work_dir
      if [ $? -eq 1 ]; then
         #pushd "$work_dir"
         "cd" $work_dir 2>>"$ERR"
         if [ $? -ne 0 ]; then
            PresentMessage ERR_BADCD $work_dir
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            get_out
         else
            loop=0
         fi
      fi
   done
   tmp_instdir1="$pgmname.$LOGNAME.$(date +%m%d%y%H%M%S)"
   tmp_instdir="$work_dir/$tmp_instdir1"
   if [ ! -d "$tmp_instdir" ]; then
      PresentMessage INFO_CREATEINSDIR temporary ${tmp_instdir}
      mkdir "$tmp_instdir" 2>>"$ERR"
      if [ ! -d "$tmp_instdir" ]; then
         PresentMessage ERR_CANTCREATEINSTDIR temporary ${tmp_instdir}
         PresentMessage INFO_CHKPERMS
         get_out
      fi
   else
      if [ -d "$tmp_instdir" ]; then
#
#       WTX00026153 - Unix unattended install prompts
#                     during install or component update
#      
        if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]]; then
          bRemove=1
        else
          yes_no 1 PROMPT_REMOVEALL $tmp_instdir
          bRemove=$?
        fi
#        
        if [[ ${bRemove} -eq 1 ]]; then
          if [ ! -z "$tmp_instdir" ]; then
            PresentMessage INFO_REMOVING
            PresentationDelay ${sleeptime_short}
            rm -rf "$tmp_instdir"  2>>"$ERR"
            if [ -d "$tmp_instdir" ]; then
              PresentMessage ERR_CANTREMOVE $tmp_instdir
              PresentMessage INFO_CHKPERMS
              get_out
            fi
            PresentationDelay ${sleeptime_long}
          else
            PresentMessage ERR_INVALIDITEM $tmp_instdir
          fi
        fi
      fi
   fi
   #popd
   "cd" "$cur_workdir" 2>>"$ERR"
   if [ $? -ne 0 ]; then
      PresentMessage ERR_CANTGETBACK $curdir
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      get_out
   fi
}
###############################################################################
# Description: Report Component file error?
###############################################################################
function chk_defdir
{
   if [ -z "$1" ]; then
      PresentMessage ERR_BADCOMPINSTFILE
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      return 0
   else
      return 1
   fi
}
###############################################################################
# Description: Receive a positive or negative response from a prior prompt.
#
# arguments: $1 - acceptable arguments range:
#            1 - y,n, or q
#            2 - y,n,q, or all
#            3 - only y or n
###############################################################################
function yes_no
{
  typeset -i loop
  typeset reply
  typeset -l lc_reply
  typeset -i yes_no_retval=-1
  typeset prompt_parms
  response_range=${1}
  response_range=${response_range:-3}
  msg_code=${2}
  shift 2
  prompt_parms=""
  for element in "$*"; do
    if [[ -z ${prompt_parms} ]]; then
      prompt_parms="${element}"
    else
      prompt_parms="${prompt_parms} ${element}"
    fi
  done
  loop=1
#   
  while [ $loop -eq 1 ]; do
    PresentMessage ${msg_code} ${prompt_parms}
#
#   If this is a silent install, assume the affirmative answer is correct.
#   Though it is not clear how a yes/no question can be successfully answered "all",
#   this is apparently what ret=2 means.
#      
    if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]] ; then
      if [[ ${response_range} = 2 ]]; then
        reply="all"
      else
        reply="y"
      fi
    else
      read reply
    fi
    lc_reply=${reply} 2>/dev/null
#
#   only allow expected responses.
#
    if [[ ${response_range} = 1 ]]; then
#
#     Check for y, n, and q      
#
      if [[ ${lc_reply} = "y" || ${lc_reply} = "yes" ]]; then
        yes_no_retval=1
      elif [[ ${lc_reply} = "n" || ${lc_reply} = "no" ]]; then
        yes_no_retval=0
      elif [[ ${lc_reply} = "q" || ${lc_reply} = "quit" ]]; then
        PresentMessage INFO_INSTTERM
        get_out           
      fi  
#
    elif [[ ${response_range} = 2 ]]; then
#
#     Check for y, n, q, and all
#
      if [[ ${lc_reply} = "y" || ${lc_reply} = "yes" ]]; then
        yes_no_retval=1
      elif [[ ${lc_reply} = "n" || ${lc_reply} = "no" ]]; then
        yes_no_retval=0
      elif [[ ${lc_reply} = "q" || ${lc_reply} = "quit" ]]; then
        PresentMessage INFO_INSTTERM
        get_out           
      elif [[ ${lc_reply} = "all" ]]; then
        yes_no_retval=2
      fi  
#
    elif [[ ${response_range} = 3 ]]; then
#
#     Check for y or n
#
      if [[ ${lc_reply} = "y" || ${lc_reply} = "yes" ]]; then
        yes_no_retval=1
      elif [[ ${lc_reply} = "n" || ${lc_reply} = "no" ]]; then
        yes_no_retval=0
      fi
    fi
#
#   if a valid response was received, exit the loop. Otherwise report the 
#   invalid response.
#
    if [[ ${yes_no_retval} -ge 0 ]]; then
      loop=0
    else
      PresentMessage ERR_BADRESPONSE ${reply:-\<space\>}
      PresentationDelay ${sleeptime_long}
    fi      
  done
  return $yes_no_retval
}
##############################################################################
# Description: Attempt to create a symbolic link
#
# Note: It is not clear what the variable "cl" represents, nor the difference
#       in the handling of the link creation.
##############################################################################
function do_link
{
  if [ "$link" != "YES" ]; then
    return 1
  fi
  typeset -i do_link_retval=0
  do_link_retval=0
  case $cl in
  "H"|"h")
    chk_file "$syslib/$s_file"
    if [ $? -eq 1 ]; then
      tmp="$(rm "$syslib/$s_file" 2>>"$ERR")"
      tmp="$(ln -f "$targdir/$s_file" "$syslib/$s_file" 2>>"$ERR")"
      if [ ! -z "$tmp" ]; then
        PresentMessage ERR_LINKFAIL $targdir/$s_file $syslib
        tmp="$(ln "-s" "$targdir/$s_file" "$syslib/$s_file" 2>>"$ERR")"
        if [ ! -z "$tmp" ]; then
          PresentMessage ERR_SYMLINKFAIL $targdir/$s_file $syslib
          return $do_link_retval
        fi
      fi
      if [ "$ostype" = "Windows_NT" ]; then
        tmp=""
      else
        if [ ! -z "$user" -a ! -z "$group" ]; then
          tmp="$(chown "$user:$group" "$syslib/$s_file" 2>>"$ERR")"
          if [ ! -z "$tmp" ]; then
            PresentMessage ERR_CHOWNFAIL $s_file $syslib
            return $do_link_retval
          fi
        fi
      fi
      PresentMessage INFO_LINKOK $s_file $syslib
    fi
    ;;
#     
  "S"|"s")
    chk_file "$syslib/$s_file"
    if [ $? -eq 1 ]; then
      tmp="$(rm "$syslib/$s_file" 2>>"$ERR")"
      fs="-s"
      if [ "$ostype" = "Windows_NT" ]; then
        fs=""
      fi
      tmp="$(ln -f "$fs" "$targdir/$s_file" "$syslib/$s_file" 2>>"$ERR")"
      if [ ! -z "$tmp" ]; then
        PresentMessage ERR_SYMLINKFAIL $targdir/$s_file $syslib
        return $do_link_retval
      fi
      if [ "$ostype" = "Windows_NT" ]; then
        tmp=""
      else
        if [ ! -z "$user" -a ! -z "$group" ]; then
          tmp="$(chown "$user:$group" "$syslib/$s_file" 2>>"$ERR")"
          if [ ! -z "$tmp" ]; then
            PresentMessage ERR_CHOWNFAIL $s_file $syslib
            return $do_link_retval
          fi
        fi
      fi
      PresentMessage INFO_SYMLINKOK $s_file $syslib
    fi
    ;;
#
  "C"|"c")
    chk_file "$syslib/$s_file"
    if [ $? -eq 1 ]; then
      tmp="$(rm "$syslib/$s_file" 2>>"$ERR")"
      tmp="$(cp -fpp "$targdir/$s_file" "$syslib/$s_file" 2>>"$ERR")"
      if [ ! -z "$tmp" ]; then
        PresentMessage ERR_COPYFAIL $targdir/$s_file $syslib
        return $do_link_retval
      fi
      if [ "$ostype" = "Windows_NT" ]; then
        tmp=""
      else
        if [ ! -z "$user" -a ! -z "$group" ]; then
          tmp="$(chown "$user:$group" "$syslib/$s_file" 2>>"$ERR")"
          if [ ! -z "$tmp" ]; then
            PresentMessage ERR_CHOWNFAIL $s_file $syslib
            return $do_link_retval
          fi
        fi
      fi
      PresentMessage INFO_COPYOK $s_file $syslib
    fi
    ;;
#     
  *)
    PresentMessage ERR_INVALIFIELD ${cl}
    PresentMessage ERR_SUPPORTINFO ${CompanyName}
    return $do_link_retval
    ;;
  esac
  return 1
}
###############################################################################
# Description: Check for prior product installation. Allow for reinstall if 
#              possible.
#
# Note: Not sure if rc=5 means something, this function requires modification to
#       adjust for what is being installed. The product tag should be obtained 
#       from the product file being processed.
#
# rc = 0 - directory ok
#    = 1 - prompt for new directory
#    = 2 - No products found in directory
###############################################################################
function chk_prod_exist
{
   typeset -i tmpY
   typeset chk_prod_exist_cd
   typeset installed_products
   typeset found_product
   typeset -i local_rc
#   
   local_rc=0
   chk_prod_exist_cd=$PWD
   re_install=0
#
#  Include extender install in existance check
#
   installed_products=$(ls ${sysdir}/IBM_WebSphere_* 2>>${ERR})
#      
   if [[ -f ${sysdir}/${common} ]]; then
     tmpY="$(cat $sysdir/$common | wc -w 2>> /dev/null)"
     if [[ ${tmpY} -lt 2 ]]; then
       rm -f $sysdir/$common 2>> "$ERR"
     fi
   fi
   find_user
   tmp_lsl="$(ls -ld $installdir)"
   set $tmp_lsl
   owner_installdir=$3
   if [[ ! -z ${installed_products} ]];then
     set ${installed_products}
     installed_products=""
     for found_product in $@;do
       if [[ ${found_product##*.} = "uninstall" || ${found_product##*.} = "readme" ]];then
         continue
       else
         installed_products="${installed_products} ${found_product}"
       fi
     done
#   
     if [[ ! -z ${installed_products} ]];then
       set ${installed_products}
       for found_product in $@;do
         found_product="${found_product##*/}"
#
         if [[ ${found_product} = "IBM_WebSphere_Transformation_Extender_Launcher_Agent" || \
               ${found_product} = "IBM_WebSphere_Transformation_Extender_SNMP_Collection" || \
               ${found_product} = "IBM_WebSphere_Transformation_Extender_Secure_Adapter_Collection" ]]; then
           continue
         elif [[ ${found_product} = ${product_name} ]];then
           re_install=1	
           some_other_product=""
           break
         else
           some_other_product=${found_product}   		
         fi
       done
     else
       local_rc=0     
     fi
#
   else
      local_rc=0
   fi	
#
   if [[ ! -z ${re_install} && ${re_install} = "1" ]]; then
#   	    
    if [ "$current_user" != "$owner_installdir" ];then
      PresentMessage ERR_NOTOWNER $installdir
      do_fail
    fi
#
#   WTX00026153 - Unix unattended install prompts
#                 during install or component update
#      
    if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]]; then
      bRemove=1
    else
      yes_no 1 PROMPT_REPLACEPROD ${product_desc}
      bRemove=$?
    fi
#
    if [[ ${bRemove} -eq 0 ]]; then
      local_rc=1
    else
      cd $sysdir 2>> "$ERR"
      if [ $PWD != "$sysdir" ]; then
        PresentMessage ERR_BADCD $sysdir
        do_fail
      fi
      PresentMessage INFO_REMOVINGPROD ${product_desc}
#
      SaveConfiguration
#      
#     Insure the uninstall script is located and can be executed.
#
      uninstall_script="${product_name}.uninstall"
      if [[ "${uninstall_script}" != "${sysdir}/${uninstall_script##${sysdir}/}"  ]]; then
        uninstall_script="${sysdir}/${uninstall_script}"
      fi
      
      if [[ -x ${uninstall_script} ]]; then
        ${uninstall_script} 2>> ${ERR}
      else
        PresentMessage WARN_REMPRODSCRIPT ${product_desc}
      fi
#
#     WTX00026876 - installation information directory missing
#                   after reinstallation.
#
      re_install="" 
      if [[ ! -d ${sysdir} ]]; then mkdir -p ${sysdir}; fi
#      
    fi
#
#   Be sure the user really wants to perform this install.
#    
  elif [[ ! -z ${some_other_product} ]]; then
    PresentMessage INFO_OTHERPRODFOUND1
    PresentMessage INFO_OTHERPRODFOUND2
#
#   WTX00026153 - Unix unattended install prompts
#                 during install or component update
#      
    if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]]; then
      bRemove=1
    else
      yes_no 1 PROMPT_CONT_REPLACEPROD
      bRemove=$?
    fi
#    
    if [[ ${bRemove} -eq 0 ]]; then
      local_rc=1
    else
#    
#     save the configuration files for some other installation found.    
#
      SaveConfiguration
    fi     
  fi
  cd $chk_prod_exist_cd 2>> "$ERR"
  return ${local_rc}
}
########################################################################################
#	check's system requirement for each component on each OS/version
#		IF exclusion from product then return 1 else returns 0
#
function system_requirement_for_comp
{
component=$1
  if [ "$ostype" = "SunOS" ];then
  	 if [ "$sun25" -eq 1 ];then
  	 	if [ "$component" = "m4r3" -o  "$component" = "javaapi1.y"  -o "$component" = "ejbapi" -o "$component" = "servletwizard"  ];then	
			return 1
	        fi
	elif [ "$sun26" -eq 1 ];then 
		if [ "$component" = "javaapi1.x" -o "$component" = "ejbapi"  -o "$component" = "servletwizard" ];then
          		return 1		
                fi
        elif [ "$sun27" -eq 1 -o "$sun28" -eq 1 -o "$sun29" -eq 1 ];then
        	if [ "$component" = "javaapi1.x" ];then
          		return 1	
                fi 
        fi  
  elif [ "$ostype" = "HP-UX" ];then 
	if [ "$hp11"   -eq 1 ];then 
		 if [ "$component" = "javaapi1.x" ];then
          		return 1	
        	 fi
        fi
  elif [ "$ostype" = "Linux" ];then
        if [ "$linux24"   -eq 1 ];then
                 if [ "$component" = "javaapi1.x" ];then
                        return 1
                 fi
        fi
  elif [ "$ostype" = "zLinux" ];then
        if [ "$zlinux26" -eq 1 ];then
                 if [ "$component" = "javaapi1.x" ];then
                        return 1
                 fi
        fi        
  elif [ "$ostype" = "AIX" ];then
        if [ "$platver" = 4 ];then
         if   [ "$int_platverm"  -lt "3" ];then
         	 if  [ "$component" = "javaapi1.y" -o  "$component" = "ejbapi"  -o "$component" = "servletwizard" ];then
         		return 1
        	 fi
	 elif [ "$int_platverm"  -gt "2" ];then
	 	if [ "$sub_oslevel" -gt 2 ];then
	 	 	if [ "$component" = "javaapi1.x" ];then
         			return 1							
        	 	fi
        	elif [ "$sub_oslevel" -lt 3 ];then
        		 if  [ "$component" = "javaapi1.y" -o  "$component" = "ejbapi"  -o "$component" = "servletwizard" ];then
         			return 1
        		 fi
        	fi
         fi
        elif [ "$platver" -gt 4 ];then
	 	 	if [ "$component" = "javaapi1.x" ];then
         			return 1							
        	 	fi
        fi
  fi
return 0
}
###############################################################################
# Description: Read and parse product file
#
# Note: This function needs significant cleanup
###############################################################################
function read_prod
{
   typeset -i p
   if [ -f "$prodfile" ]; then
      compnum=0
      valnum=0
      linenum=1
      exec 5< $prodfile
      while read -u5 line
      do
         if [ "$linenum" -eq 1 ]; then
            linenum=0
            if [ "$line" != "DTX_Product_File" ]; then
               PresentMessage ERR_INVPRODFILE
               PresentMessage INFO_INSTTERM
               PresentMessage ERR_SUPPORTINFO ${CompanyName}
               do_fail
            else
               continue
            fi
         fi
         if [ "$line" = "" ]; then
            continue
         fi
         set $line
         one_char=$1
         if [ "$one_char" = "#" ]; then
            continue
         fi
         if [ $# -lt 2 ]; then
            PresentMessage ERR_BADLINEPROD
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            do_fail
         fi
         if [ "$1" = "PRODUCT" ]; then
            shift
            product_name=$1
            if [ "$info_prod" != "$product_name" ]; then
               PresentMessage INFO_INFODATAFILE $infofile $tmp
               PresentMessage ERR_INFONOMATCH $prodfile
               PresentMessage ERR_SUPPORTINFO ${CompanyName}
               do_fail
            fi
            shift
            product_version=$1
            shift
            product_desc=$@
            lenp="${#info_desc}"
            continue
         fi
         if [ "$1" = "SYSTEM" ]; then
            shift
            if [ "$1" != "$ostype" ]; then
               PresentMessage ERR_CANTINSTALLPROD
               PresentMessage ERR_BADINSTVERSION $ostype $1
               PresentMessage ERR_SUPPORTINFO ${CompanyName}
               do_fail
            fi
            shift
            tmp=$1
            one_char="$tmp"
            tmp1=${tmp#?}
            case $one_char in
               ">")
                    if [ "$tmp1" -lt "$osver" ]; then
                      PresentationDelay ${sleeptime_long}
                    fi
                    ;;
#          
               "#")
                    if [ "$tmp1" -ne "$osver" ]; then
                       PresentMessage INFO_INFOANYOS $osver
                       PresentMessage INFO_INSTALLALLOWED
                    fi
                    ;;
#          
               "=")
                    if [ "$tmp1" -ne "$osver" ]; then
                       PresentMessage ERR_CANTINSTALLPROD
                       PresentMessage ERR_BADINSTVERSION $osver $tmp1
                       PresentMessage ERR_SUPPORTINFO ${CompanyName}
                       do_fail
                    fi
                    ;;

               *)
                    if [ "$tmp" -lt "$osver" ]; then
                       PresentationDelay ${sleeptime_long}
                    fi
                    ;;
            esac
#
#           retrieve package word size definition. If not specified
#           this value will default to 32 (bit).
#
            shift 
            Package_Wordsize=$1
            Package_Wordsize=${Package_Wordsize:-32}
#                        
         continue
         fi
         if [ "$1" = "COMPONENT" ]; then
            #shift
            #component_name=$@
            continue
         fi
         if [ "$1" = "PRODVER" ]; then
            pver=$2
            pverlong=$3
            continue
         fi
         if [ "$1" = "PREREQ" ]; then
            shift
            prereq[$prereqnum]=$@
            prereqnum=$prereqnum+1
            continue
         fi
         if [ "$1" = "LINK" ]; then
            link="yes"
            continue
         fi
         if [ "$1" = "LIB" ]; then
            lib="yes"
            libx="libs/"
            binx="bin/"
            continue
         fi
         if [ "$1" = "LAUNCHER" ]; then
            launcher="yes"
            continue
         fi
         if [ "$1" = "JAVA" ]; then
            java="yes"
            continue
         fi
         if [ "$1" = "SUB_DIR" ]; then
            if [ ! -z "$2" -a ! -z "$3" ]; then
               psubdir="$psubdir $2 $3"
            else
               PresentMessage ERR_BADSUBDIR $prodfile
               PresentMessage ERR_SUPPORTINFO ${CompanyName}
               do_fail

            fi
            continue
         fi
         if [ "$1" = "PACKAGE" ]; then
            if [ 0 = 1 ]; then
               if [ $packnum -ne 0 ]; then
                  wait_for_enter
               fi
            fi
            packnum=$packnum+1
            shift
            package_name=$1
            shift
            package_desc=$@
            if [ -z "$package_desc" ]; then
               package_desc="$package_name"
            fi
            continue
         fi
#
         component="$1"
         shift
         compos=$1
         shift
         composver="$1"
         shift
         prodver="$1"
         shift
         compname="$1"
         if [ "$compname" = "Shared_Files" ];then
         	Total_Shared_Components=$Total_Shared_Components+1
         fi
         shift
         #compdesc=$@
 	 compdesc=""
 	 for compdesc1 in $@
 	 do
 	    
 	   if [ "$compdesc1" = "NO" -o "$compdesc1" = "YES" ];then
 	    visibility=$compdesc1
 	   else
 	    compdesc="$compdesc $compdesc1"
 	   fi
 	 done
         if [ -z "$compdesc" ]; then
            PresentMessage ERR_NODESC $component
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            do_fail
         fi
         if [ -z "$compname" ]; then
            PresentMessage ERR_NONAME $component
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            do_fail
         fi
         one_char=$composver
         compindex=$(( ${arraysize} * ${compnum} ))
         prod[(${compindex} + ${ix_component})]="$component"
         prod[(${compindex} + ${ix_compfile})]=""
         prod[(${compindex} + ${ix_compver})]="$compver"
         prod[(${compindex} + ${ix_composver})]="$composver"
         prod[(${compindex} + ${ix_compname})]="$compname"
         prod[(${compindex} + ${ix_comptarfile})]=""
         prod[(${compindex} + ${ix_compdesc})]="$compdesc"
         prod[(${compindex} + ${ix_compos})]="$compos"
         prod[(${compindex} + ${ix_nvalid})]="invalid"
         prod[(${compindex} + ${ix_product_name})]="$product_name"
         if [ ! -z "$product_name" ]; then
            prod[(${compindex} + ${ix_package_name})]="$package_name"
            prod[(${compindex} + ${ix_package_desc})]="$package_desc"
         fi
         prod[(${compindex} + ${ix_select})]=""
         prod[(${compindex} + ${ix_overwrite})]=""
         prod[(${compindex} + ${ix_curinstall})]=""
         #Increase Arraysize if increasing features
         prod[(${compindex} + ${ix_visible})]="$visibility"
         
         if [ "$compos" != "$ostype" ]; then
            PresentMessage INFO_ALLTERMS  $compdesc
            PresentMessage ERR_OSNOMATCH ${compos} ${ostype}
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            compnum=$compnum+1
            continue
         fi
         case $one_char in
            ">")
                           composver=${composver#?}
                           if [ "$composver" -le "$osver" ]; then
                              compfile=$component"_"$composver"."$ostype
                              prod[(${compindex} + ${ix_compfile})]="$compfile"
                              comptarfile=$tmp_instdir"/"$component"_"$composver".tar"
                           else
                              PresentMessage ERR_NOFFOROS $compdesc ${osver}
                              PresentMessage ERR_SUPPORTINFO ${CompanyName}
                              do_fail
                              compnum=$compnum+1
                              continue
                           fi
                           ;;
            "#")
                           compfile=$component"."$ostype
                           prod[(${compindex} + ${ix_compfile})]="$compfile"
                           comptarfile=$tmp_instdir"/"$component".tar"
                           prod[(${compindex} + ${ix_comptarfile})]="$comptarfile"
                           ;;
            "=")
                           compfile=$component"_"$composver"."$ostype
                           composver=${composver#?}
                           if [ "$osver" = "$composver" ]; then
                              prod[(${compindex} + ${ix_compfile})]="$compfile"
                              comptarfile=$tmp_instdir"/"$component"_"$composver".tar"
                              prod[(${compindex} + ${ix_comptarfile})]="$comptarfile"
                           else
                              PresentMessage ERR_NOFFOROS $compdesc ${osver}
                              PresentMessage ERR_SUPPORTINFO ${CompanyName}
                              do_fail
                              compnum=$compnum+1
                              continue
                           fi
                           ;;

            *)             PresentMessage ERR_INVOSVER
            		   PresentMessage ERR_SUPPORTINFO ${CompanyName}
                           do_fail
                           ;;

         esac
         prod[(${compindex} + ${ix_comptarfile})]="$comptarfile"
#
#        non-visible components are always selected
#
         if [[ ! -z ${prod[(${compindex} + ${ix_visible})]} && \
               ${prod[(${compindex} + ${ix_visible})]} != "YES" ]]; then
            prod[(${compindex} + ${ix_select})]=1
         fi
#         
         p="$compnum"%6
         
         system_requirement_for_comp "$component"
         return_value=$?
         if [ "$return_value" -eq 1 ];then
         	PresentMessage INFO_ONETERM " "
         else
         	compnum=$compnum+1
         fi
                 
         if [ ! -f "$comptarfile" ]; then
            PresentMessage ERR_MISSINGTAR $comptarfile $compdesc
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            do_fail
            continue
         fi
         valnum=$valnum+1
         prod[($arraysize*($compnum-1))+8]="valid"
      done
      exec 5<&-
   else
      PresentMessage ERR_INVPRODFILE
      PresentMessage INFO_INSTTERM
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
   fi
   package_name=""
}
##########################################################################################
# Description - print a header section break of a specified length
##########################################################################################
function hdr_underline
{
  typeset -i curpos
  typeset -i count
  count=${1}
  fillchar=${2}
  if [[ -z ${fillchar} ]]; then fillchar='-'; fi
  if [[ -z ${count} ]]; then
    count=0
  fi 
  curpos=0
  while [[ ${curpos} -lt ${count} ]]; do
    print -- "${fillchar}\c"
    curpos=$(( ${curpos} + 1 ))
  done
  print "\n"
}
###############################################################################
# Description: Display identified products parsed from product file
###############################################################################
function display_prod
{
   typeset -i pn
   #set -x
   typeset -i lenp
   DisplayMessage ${MSG_INFO} "$product_desc"
#   pn=0
   hdr_underline ${#product_desc} '-'
   pn=0
   package_n=""
   while [ $pn -lt $compnum ]; do 
     compdesc=${prod[($arraysize*$pn)+${ix_compdesc}]}
     package_name=${prod[($arraysize*$pn)+${ix_package_name}]}
     package_desc=${prod[($arraysize*$pn)+${ix_package_desc}]}
     visible_component=${prod[($arraysize*$pn)+${ix_visible}]}
     #xx=${prod[($arraysize*$pn)+${ix_curinstall}]}
     #yy=${prod[($arraysize*$pn)+16]}         # ??
     #zz=${prod[($arraysize*$pn)+${ix_overwrite}]}
     if [ "$compvalid" = "invalid" ]; then
       compvalid="***** $compvalid *****"
     else
       compvalid=""
     fi
      if [ "$package_name" != "$package_n" -a "$visible_component" = "YES" ]; then
         DisplayMessage ${MSG_INFO} "$package_desc"
         package_n="$package_name"
      fi
      if [ "$compdesc" != "$package_desc" -a "$visible_component" = "YES" ]; then
         DisplayMessage ${MSG_INFO} "   $compdesc   $compvalid"
      else
         if [ $pn+1 -lt $compnum ]; then
            if [ "$package_name" = "${prod[($arraysize*($pn+1))+10]}" -a "$visible_component" = "YES" ]; then
               DisplayMessage ${MSG_INFO} "   $compdesc   $compvalid"
            fi
         fi
      fi
      pn=$pn+1
   done
}
###############################################################################
# Description: ??
# 
# Note: not clear if this is product or component prereq. Prerequisites should
#       come from product or component file
###############################################################################
function check_prereq
{
   typeset -i num=0
   typeset tmp
   typeset -i n
   while [ $num -lt $prereqnum ]; do
      tmp="${prereq[$num]}"
      set $tmp
      pre=$1
      shift
      dep=$@
      for r in $reply; do
         n=$r
         tmp="${prod[($arraysize*($n-1))+$ix_component]}"
         if [ "$pre" = "$tmp" ]; then
            chk_allin
            if [ $? -eq 1 ]; then
               return $num
            fi
         fi
      done
      num=$num+1
   done   
   return 255
}
###############################################################################
# Description: ??
###############################################################################
function chk_allin
{
   typeset -i preno=0
   typeset -i c
   typeset -i n
   set $dep
   c=$#
   for inn in $dep; do
      for ll in $reply; do
         n=$ll
         tmp="${prod[($arraysize*($n-1))+$ix_component]}"
         if [ "$inn" = "$tmp" ]; then
            preno=$preno+1
            break;
         fi
      done
   done
   if [ $preno -eq $c ]; then
      return 0
   fi
   return 1
}
###############################################################################
# Description: same as Remove_Overwritten_Deleted_Files but for Moved Files
###############################################################################
function Remove_Moved_File
{
moved_file=$1
rename_file=$2
tmp="$(grep "$rename_file " $sysdir/$common  2>>/dev/null )" 
if [ ! -z "$tmp" ];then
        set $tmp
        if [ "$1" = "$rename_file" ];then
                tmp1="$tmp $modified_product_name"
	        ex - $sysdir/$common << EOD
                %s,$tmp,$tmp1
                wq
EOD
        fi
        Remove_Overwritten_Deleted_Files $moved_file
else
  	tmp="$(grep "$moved_file " $sysdir/$common  2>>/dev/null )"
        if [ ! -z "$tmp" ];then
          set $tmp
          if [ "$1" = "$moved_file" -a ! -z "$rename_file" ];then
                ex - $sysdir/$common << EOD
                %s,$moved_file,$rename_file
                wq
EOD
          fi
  	fi
fi
}
###############################################################################
# Description: For deleted files or file already existed
###############################################################################
function Remove_Overwritten_Deleted_Files
{
moved_file=$1
tmp="$(grep -n "$moved_file " $sysdir/$common  2>>/dev/null )"
if [ ! -z "$tmp" ];then 
  tmp1="${tmp%%:*}"
  if [ ! -z "$tmp1" ];then
    ex - $sysdir/$common << EOD
    ${tmp1}d
    wq
EOD
  fi
fi 
}
###############################################################################
# Description: Apparently, remove a list item
#
# Note: This function appears only to duplicate comment lines and remove lines
#       that have a single token. Not really sure that this is useful
###############################################################################
function remove_from_list
{
typeset -L1 first_char1
exec 5< $sysdir/$common
while read -u5 line
do
  if [[ ${line} = "" ]]; then
    continue
  fi
  first_char1=$line
  if [[ ${first_char1} = "#" ]];then
    print "$line" >> $sysdir/.List_tmp    
  fi
  set $line
  if [[ $# -gt 1 ]];then
    print "$line" >> $sysdir/.List_tmp   
  fi   	        		
done
exec 5<&-
mv $sysdir/.List_tmp $sysdir/$common
}
###############################################################################
# Description: Apparently, replace an entry in the "$common" file.
###############################################################################
function modify_List
{
#set -x
File=$1
Product_name=$2
tmp="$(grep "$File " $sysdir/$common)" 
if [ ! -z "$tmp" ];then
	grep -v "$File " $sysdir/$common >> $sysdir/.List_tmp
	print "$tmp $Product_name"  >> $sysdir/.List_tmp
	mv $sysdir/.List_tmp $sysdir/$common
fi
}
###############################################################################
# Description: Apparently, copy to common
###############################################################################
function copy_to_common
{
  tmp_file=$1
  tmp_dir=$2
  if [ "${tmp_dir##*/}" = "libs" ];then
  	files_in_libs="$files_in_libs $tmp_dir/$tmp_file"
  fi
  if [ -f "$tmp_dir/$tmp_file" ];then
        tmp="$(grep $tmp_dir/$tmp_file $sysdir/$common)"
        if [ ! -z "$tmp" ];then
        	modify_List  $tmp_dir/$tmp_file $product_name
        fi        
  elif [ ! -f "$tmp_dir/$tmp_file" ];then
  	print "$tmp_dir/$tmp_file $product_name" >> $sysdir/$common
  fi
}
###############################################################################
# Description: Apparently, create a component removal script
###############################################################################
function create_Remove
{
    uninstall=$1
    print "function Remove { "  				 >> "$uninstall"
    print "RemoveFile=\$1" 					 >> "$uninstall"
#
#   for redundant file removal if file not present then return; 22jun2006
    print "if [ ! -f \"\$RemoveFile\" ] && [ ! -h \"\$RemoveFile\" ]; then" \
                                                                 >> "$uninstall"
    print "\treturn"                                             >> "$uninstall"
    print "fi"                                                   >> "$uninstall"
#   Adding test for .List - if not present then just remove file - per David R.    
    print "if [ ! -f \"$sysdir/$common\" ]; then"                >> "$uninstall"
    print "\trm -f \$RemoveFile  2>>$NUL"                        >> "$uninstall"
    print "\treturn"                                             >> "$uninstall"
    print "fi"                                                   >> "$uninstall"    
    print "tmp=\"\$(grep \"\$RemoveFile \" $sysdir/$common  2>>$NUL )\" " >> "$uninstall"
    print "if [ -z \"\$tmp\" ];then " 					  >> "$uninstall"
    print "     rm -f \$RemoveFile  2>>$NUL" 	 			  >> "$uninstall"
    print "else \n\t set \$tmp \n\t if [ \"\$1\" = \"\$RemoveFile\" ];then" >> "$uninstall"
    print "\t\tprint \"\$tmp\" > $sysdir/$file_tmp" 			   >> "$uninstall"
    print "\t\tex - $sysdir/$file_tmp <<EOD \n\t\t %s,$product_name,  \n\t\t wq" >> "$uninstall"
    print "EOD" 				   >> "$uninstall"
    print "\t\ttmp_cat=\"\$(cat $sysdir/$file_tmp 2>>$NUL )\" " >> "$uninstall"
    print "\t\trm -f $sysdir/$file_tmp 2>>$NUL "  >> "$uninstall"
    print "\t\tex - $sysdir/$common <<EOD \n\t\t %s,\$tmp,\$tmp_cat \n\t\t wq" >> "$uninstall"
    print "EOD" 				   >> "$uninstall" 
    print "\t\tif [ ! -z \"\$tmp_cat\" ];then"       >> "$uninstall" 
    print "\t\t\tset \$tmp_cat \n\t\t\tif [ \$# -lt 2 ];then"                >> "$uninstall"
    print "\t\t\t\trm -f \$RemoveFile  2>>$NUL \n\t\t\tfi \n\t\tfi \n\t fi \nfi \n}"  >> "$uninstall"
}
###############################################################################
# Description: Install component from component description file
#
# Note: Several cases are disabled in this function. As well, some of the processing
#       present is duplicated in other functions. As such, there is significant room
#       for clean up.
###############################################################################
function inscomp
{
   typeset curdir
   typeset -i i
   typeset -i k
   typeset -i inscomp_retval
   typeset comp_shared                    # Shared component flag
   typeset comp_overwrite                 # Component file overwrite flag
   typeset replace_opt                    # replacement options
   Component_Wordsize=${Package_Wordsize}
   linenum=1
   inscomp_retval=0
   comp_shared=TRUE
   comp_overwrite=TRUE
   comp_wordsize=${Component_Wordsize}
   
   component=$1
   compfile="$2"
   comptarfile="$3"
   
   if [ ! -s $comptarfile ]; then
      PresentMessage ERR_INVCOMPTAR $comptarfile
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
      #return $inscomp_retval
   fi
   if [[ $printflag != 1 ]]
   then
      PresentMessage INFO_EXTRACTINGTAR $comptarfile
   fi
   tar -xf "$comptarfile" 2>>"$ERR"
   if [ $? -gt 0 ]; then
   	PresentMessage ERR_EXTRACTERR $comptarfile
   	PresentMessage ERR_SUPPORTINFO ${CompanyName}
   	do_fail
   fi
   rm -f "$comptarfile" 2>>"$ERR"
   if [ ! -f "$compfile" ]; then
      PresentMessage ERR_INVCOMPTAR ${1}
      PresentMessage INFO_INSTTERM
      return $inscomp_retval
   fi
   if [[ $printflag != 1 ]]
   then
     PresentMessage INFO_INSTALLING $compdesc 
   fi  
   if [ 0 -eq 1 ]; then
      tmp="$(ls "$installdir" 2>>"$ERR")"
      if [ ! -z "$tmp" ]; then
         yes_no 1 PROMPT_OVERWRITEPROD $installdir
         if [ $? -eq 0 ]; then
            PresentMessage INFO_BYPASSINGCOMP $compdesc
            install_notselect=$install_notselect+1
            return $inscomp_retval
         fi
      fi
   fi
   sysfile="$sysdir/$compfile"
   uninstall="$sysdir/$component.uninstall"
   print "#!/bin/ksh" > "$uninstall"
   print "# Uninstall script for $component" >> "$uninstall"
   chmod ug+x "$uninstall"
   if [ ! -z "$user" -a ! -z "$group" ]; then
      tmp="$(chown "$user:$group" "$uninstall" 2>>"$ERR")"
   fi
   replace_opt="ALWAYS"
   create_Remove	$uninstall

   exec 6< $compfile
   while read -u6 line
   do
      if [ $linenum -eq 1 ]; then
         linenum=0
         if [ "$line" != "DTX_Component_Install_File" ]; then
            PresentMessage ERR_COMPHDRMISSING
            PresentMessage ERR_SUPPORTINFO ${CompanyName}
            $install_error=$install_error+1
            do_fail
            break
         else
            continue
         fi
      fi
      if [ "$line" = "" ]; then
         continue
      fi
      set $line
      one_char=$1
      if [ "$one_char" = "#" ]; then
         continue
      fi
      if [ $# -lt 2 ]; then
         PresentMessage ERR_COMPINVLINE
         PresentMessage ERR_SUPPORTINFO ${CompanyName}
         $install_error=$install_error+1
         PresentMessage INFO_COMPLINEINERR ${line}
         do_fail
         break
      fi
      typeset -u "$1"
# some of these case statements are disabled - not currently used (if [ 0 -eq 1 ])
      case $1 in
         "REPLACE")
           replace_opt=$2
           if [[ -z ${replace_opt} || ${replace_opt} != "IFEXIST" ]]; then
             replace_opt="ALWAYS"
           fi
           ;;      
         "COMPONENT")
                        if [ 0 -eq 1 ]; then
                           compins=$2
                        fi
                        ;;
         "DESCRIPTION")
                        if [ 0 -eq 1 ]; then
                           shift
                           describe=$@
                        fi
                        ;;
         "VERSION")
                        if [ 0 -eq 1 ]; then
                           version=$2
                        fi
                        ;;
         "OS")
                        if [ 0 -eq 1 ]; then
                           os=$2
                           if [ "$ostype" != $os ]; then
                              PresentMessage ERR_INVOS $os
                              PresentMessage INFO_COMPOSTYPE ${os}
                              PresentMessage INFO_OSTYPE:OS ${ostype}
                              return $inscomp_retval
                           fi
                        fi
                        ;;
         "OS_LEVEL")
                        if [ 0 -eq 1 ]; then
                           oslevel=$2
                           if [ "$oslevel" != "$osver" ]; then
                              PresentMessage ERR_INVOSLEVEL
                              PresentMessage INFO_OSLEVEL ${osver}
                              PresentMessage INFO_COMPOSLEVEL ${oslevel}
                              PresentMessage ERR_SUPPORTINFO ${CompanyName}
                              return $inscomp_retval
                           fi
                        fi
                        ;;
         "SUB_DIR")
                        sub_dir=$2
                        perm=$3
                        one_char=$sub_dir
                        if [ "$one_char" != "/" ]; then
                           sub_dir=$installdir"/"$sub_dir
                        fi
                        if [ ! -d $sub_dir ]; then
                           mkdir -m $perm -p $sub_dir
                           if [ ! -d "$sub_dir" ]; then
                              PresentMessage ERR_SUBDIRERR ${sub_dir}
                              return $inscomp_retval
                           else
                              PresentMessage INFO_DIRCREATED ${sub_dir} ${perm}
                              allsubdir="$allsubdir $sub_dir"
                           fi
                        fi
                        if [ "$ostype" = "Windows_NT" ]; then
                           tmp=""
                        else
                           if [ ! -z "$user" -a ! -z "$group" ]; then
                              tmp="$(chown "$user:$group" "$sub_dir" 2>>"$ERR")"
                              if [ ! -z "$tmp" ]; then
                                 PresentMessage ERR_CHOWNERR $sub_dir
                                 return $inscomp_retval
                              fi
                           fi
                        fi
                        ;;
         "CHKSUM")
                        if [ 0 -eq 1 ]; then
                           chksum=$2
                        fi
                        ;;
         "WORDSIZE")            
                        comp_wordsize=$2
                        ;;
         "MOVE")
                        file=$2
                        newfile=$3
                        if [ "$lib" = "yes" ]; then
                           srcdir=$4
                           targdir=$5
                        else
                           srcdir="./"
                           targdir="./"
                        fi
                        tmpdir="$installdir"
                        if [ "$targdir" = "." -o "$targdir" = "./" ]; then
                           tmpdir="$installdir"
                        else
                           tmpdir="$installdir/$targdir"
                        fi
                        if [ "$srcdir" = "." -o "$srcdir" = "./" ]; then
                           srcfile="$installdir/$file"
                        else
                           srcfile="$installdir/$srcdir/$file"
                        fi
                        perm=$6
#                        
                        #
                        # If replacement options indicate the file must exist
                        # insure the target exists prior to the move.
                        #
                        if [[ ! -z ${replace_opt} && ${replace_opt} = "IFEXIST" ]]; then
                          if [[ ! -f ${tmpdir}/${newfile} ]]; then
                            continue
                          fi
                        fi
#                        
                        mv "$srcfile" "$tmpdir/$newfile" 2>>"$ERR"
         		Remove_Moved_File $srcfile "$tmpdir/$newfile"
                        if [ ! -f "$tmpdir/$newfile" ]; then
                           PresentMessage ERR_MOVEERR $srcfile $newfile $tmpdir
                           return $inscomp_retval
                        else
                           if [[ $printflag != 1 ]]
   			   then
                             PresentMessage INFO_MOVED $srcfile $newfile $tmpdir
                           fi
                           print "Remove $tmpdir/$newfile 2>>$NUL" >> "$uninstall"
                           
                        fi
                        ;;
         "FILE")	
           s_file=$2
           t_file=$3
           srcdir=$4
           targdir=$5
           perm=$6
           syslib=$7
           cl=$8
#           
#          04/02/01: Resolve TR 6849 so that either threaded 
#          or non-threaded shared/libplatapi*.so gets installed
#
           if [ "$shared_plat" -eq 1 -a "$t_file" = "libplatapi.so" ];then
             continue
           elif [ "$shared_plat" -eq 0 -a "$t_file" = "libplatapi_nothr.so" ];then
             continue
           fi
#
           if [[ ${lib} != "yes" ]]; then
             targdir="./"
           fi
           one_char="$syslib"
           if [[ ! -z ${one_char} ]]; then
             if [[ ${one_char} != "/" ]]; then
               syslib="$PWD/$syslib"
             fi
           fi
           if [[ ${srcdir} = "." || ${srcdir} = "./" ]]; then
             srcfile="$s_file"
           else
             srcfile="$srcdir/$s_file"
           fi
           if [[ ${targdir} = "." || ${targdir} = "./" ]]; then
             targdir="$installdir"
           else
             targdir="$installdir/$targdir"
           fi
#                        
#                       if [ "$hp10" -eq 1 ];then
#                         if [ "$component" = "engine" -o  "$component" = "engineINT" ];then
#                           if [ "$engine_to_uninstall" = "0" ];then
#                             print "Remove $tmpdir/dtxcmdsv 2>>$NUL" >> "$uninstall"
#                             engine_to_uninstall=1
#                           fi
#                         fi
#                         if [ "$component" = "launcher" -o  "$component" = "launcherINT" ];then
#                           if [ "$launcher_to_uninstall" = "0" ];then
#                             print "Remove $tmpdir/launcher 2>>$NUL" >> "$uninstall"
#                             launcher_to_uninstall=1
#                           fi	
#                         fi
#                       fi

#
#          For the ALL_FILES directive, copy all files present in the 
#          component extraction directory.
#
           if [[ ${s_file} = "ALL_FILES" ]]; then
             srcdir=$(pwd)
             allfiles="$(ls -a 2>> "$ERR")"
             while [ ! -z "$allfiles" ]; do
               s_file=${allfiles%% *}
               if [[ ! -z ${s_file} ]]; then 
                 t_file=${s_file}
                 if [ -f "$t_file" -a "$t_file" != $component -a "$t_file" != "." -a "$t_file" != ".." -a "$t_file" != "$instfile" -a "$t_file" != "$prodfile" ]; then
#                  #
                   # If replacement options indicate the file must exist
                   # insure the target exists prior to the move.
                   #
                   if [[ ! -z ${replace_opt} && ${replace_opt} = "IFEXIST" ]]; then
                     if [[ ! -f ${targdir}/${t_file} ]]; then
                       continue
                     fi
                   fi
#
                   DoCopy ${s_file} ${t_file} ${srcdir} ${targdir} ${comp_overwrite} ${perm} ${uninstall}
                 fi
                 allfiles=${allfiles#${s_file} }
               else
                 break
               fi  
             done
             break
           elif [[ "${sfile%\.tar}.tar" = ${s_file} ]]; then
#
#            Apparently, tar files encountered are extracted
#                        
             tarcurdir=$PWD
             cd ${targdir} 2>>${ERR}
             if [[ $? -ne 0 ]]; then
               PresentMessage ERR_BADCD $targdir
               return $inscomp_retval
             fi
             if [[ $printflag != 1 ]]; then
               PresentMessage INFO_EXTRACTINGTAR $srcfile
             fi
             tmp="$(tar -xf "$srcfile" 2>>"$ERR")"
             "cd" "$tarcurdir" 2>>"$ERR"
             if [[ $? -ne 0 ]]; then
               PresentMessage ERR_CANTGETBACK $tarcurdir
               return $inscomp_retval
             fi
           else
#
#            regular file to position
#			  
             #
             # If replacement options indicate the file must exist
             # insure the target exists prior to the move.
             #
             if [[ ! -z ${replace_opt} && ${replace_opt} = "IFEXIST" ]]; then
               if [[ ! -f ${targdir}/${t_file} ]]; then
                 continue
               fi
             fi
#
             DoCopy ${s_file} ${t_file} ${srcdir} ${targdir} ${comp_overwrite} ${perm} ${uninstall}
#		          
           fi
           ;;
#
         "LN")
                        s_file=$2
                        targdir=$3
                        perm=$4
                        syslib=$5
                        if [ ! -z "$one_char" ]; then
                           if [ "$one_char" != "/" ]; then
                              syslib="$PWD/$syslib"
                           fi
                        fi
                        cl=$6
                        if [ "$targdir" = "." -o "$targdir" = "./" ]; then
                           targdir="$installdir"
                        else
                           targdir="$installdir/$targdir"
                        fi
                        if [ ! -z "$syslib" -a ! -z "$cl" ]; then
                           do_link
                           if [ $? -eq 0 ]; then
                              return $inscomp_retval
                           fi
                        fi
                        ;;

         "LINKDEF")
           linktarget=$2
           linkname=$3
           perm=$4
           if [[ "/${linktarget#/}" != ${linktarget} ]]; then
             linktarget=${installdir}/${linktarget}
           fi
           if [[ "/${linkname#/}" != ${linkname} ]]; then
             linkname=${installdir}/${linkname}
           fi
           perm=${perm:-755}
           Def_links[${#Def_links[*]}]="${replace_opt:-ALWAYS};${comp_overwrite};${comp_shared};${linktarget};${linkname};${perm};${uninstall}"
           ;;
         
         "LINK")
           linktarget=$2
           linkname=$3
           perm=$4
           if [[ "/${linktarget#/}" != ${linktarget} ]]; then
             linktarget=${installdir}/${linktarget}
           fi
           if [[ "/${linkname#/}" != ${linkname} ]]; then
             linkname=${installdir}/${linkname}
           fi
           perm=${perm:-755}
           new_dolink ${replace_opt:-ALWAYS} ${comp_overwrite} ${comp_shared} ${linktarget} ${linkname} ${perm} ${uninstall}
           rc=$?
           if [[ ${rc} = 0 ]]; then
             PresentMessage INFO_LINKOK ${linkname} ${linktarget}           
           else
             PresentMessage ERR_SYMLINKFAIL ${linkname} ${linktarget}
           fi
           ;;
                        
         "EXECUTE")
           file=$2
           srcdir=$3
           tmpdir="$installdir"
           if [ "$srcdir" = "." -o "$srcdir" = "./" ]; then
             tmpdir="$installdir"
           elif [[ "/${srcdir#/}" = ${srcdir} ]]; then
             tmpdir=${srcdir}
           else
             tmpdir="$installdir/$srcdir"
           fi
#
           exec_string="${tmpdir}/${file}"
           if [[ $printflag != 1 ]]; then
             PresentMessage INFO_EXECUTING ${exec_string}
           fi
#
#          if the requested execution file exists, try to insure
#          it is executeable.
#
           if [[ -f ${exec_string} ]]; then
             if [[ ! -x ${exec_string} ]]; then
               chmod a+x ${exec_string} 2>>"$ERR"
             fi
             rc=0
#
#            named execution file not found, try to resolve it.
#             
           else
             whence ${exec_string} > /dev/null 2>&1
             rc=$?
             if [[ ${rc} != 0 ]]; then
               PresentMessage ERR_EXENF ${exec_string}
             fi
           fi
#
#          if the named executable can likely be run, do so
#
           if [[ ${rc} = 0 ]]; then
#
#            if logging has been requested, capture the output
#            produced by the external execution.
#
             if [[ ! -z ${loggingfile} ]]; then
               PresentMessage INFO_EXELOG "Start" ${exec_string}
               exec_string="${exec_string} | tee -a ${loggingfile}"
             fi
#             
             ${exec_string}
#
             if [[ ! -z ${loggingfile} ]]; then
               PresentMessage INFO_EXELOG "End" ${exec_string}
             fi
           fi
#           
           ;;
#           
         "SHARE")
#
#          Files in this component are to be recorded 
#          as shared. If a prior copy is located, the file
#          reference count is updated.
#
#          NOT YET IMPLEMENTED IN A MEANINGFUL WAY
#
           if [[ ${2} = "NO" ]]; then
             comp_shared=0
           else
             comp_shared=1
           fi
           ;;
#
         "OVERWRITE")
#
#          File collision resolution for objects included in this
#          component. Currently allowed values are:
#          ALWAYS (default) -  overwrite object
#          NEVER - do not overwrite
#
           if [[ ${2} = "NEVER" ]]; then
             comp_overwrite=0
           else
             comp_overwrite=1
           fi
           ;;
#                                 
         *)
           PresentMessage ERR_INVALIFIELD ${1}
           PresentMessage ERR_SUPPORTINFO ${CompanyName}
           ;;
      esac
   done
   exec 6<&-
   inscomp_retval=1
   return $inscomp_retval
}
#######################################################
# DoCopy - Perform file copy activities
#
# Args:
# 1 - source file name
# 2 - target file name
# 3 - source directory
# 4 - target directory
# 5 - overwrite indicator
# 6 - permissions
# 7 - Removal file
#######################################################
function DoCopy {
  s_file=${1}
  t_file=${2}
  srcdir=${3}
  targdir=${4}
  comp_overwrite=${5}
  perm=${6}
  uninstall=${7}
#
# ec 73581 - remove links prior to copy for core installs
#			  
  bCopy="FALSE"	 
  if [[ ${comp_overwrite} = 1 ]]; then
    if [[ -h "$targdir/$t_file" || -L "$targdir/$t_file" ]]; then
      if [[ ${inst_type} = "CORE" ]]; then
        rm -f ${targdir}/${t_file}
        bCopy="TRUE"
      fi
    else
      bCopy="TRUE"
    fi
  else
    if [[ ! -f "${targdir}/${t_file}" ]]; then
      bCopy="TRUE"
    fi
  fi
#		          
  if [[ ${bCopy} = "TRUE" ]]; then
#
#   TR 8575 - failing to uninstall some files which have "$" sign
#   in their filename
#
    rm_file=${t_file}
    if [[ ${t_file} != ${t_file%\$*} ]]; then
      rm_file="${t_file%\$*}\\\$${t_file#*\$}"
    fi
#
    copy_to_common $file $tmpdir
    cp -fp "$srcdir/$s_file" "$targdir/$t_file" 2>>"$ERR"
#			  	 
    if [[ ! -f "$targdir/$t_file" ]]; then
      PresentMessage ERR_COPYERR $srcfile $targdir
      return $inscomp_retval
    else
      if [[ $printflag != 1 ]]; then
        PresentMessage INFO_COPYOK $srcfile $targdir
      fi
      if [[ "$ostype" = "Windows_NT" ]]; then
        tmp=""
      else
        if [[ ! -z ${user} && ! -z ${group} ]]; then
          tmp="$(chown "$user:$group" "$targdir/$t_file" 2>>"$ERR")"
          if [[ ! -z ${tmp} ]]; then
            PresentMessage ERR_CHOWNFAIL $t_file $targdir
            return $inscomp_retval
          fi
        fi
      fi
#
      print "Remove $targdir/$rm_file 2>>$NUL" >> "$uninstall"
#
      if [[ ! -z ${perm} ]]; then
        tmp="$(chmod "$perm" "$targdir/$t_file" 2>>"$ERR")"
        if [[ ! -z ${tmp} ]]; then
          PresentMessage ERR_PERMISSION $perm $targdir/$t_file
          return $inscomp_retval
        else
          if [[ $printflag != 1 ]]; then
            PresentMessage INFO_PREMSET $targdir/$t_file $perm 
          fi
        fi
      fi
      if [[ ! -z ${syslib} && ! -z ${cl} ]]; then
        do_link
        if [[ $? -eq 0 ]]; then
          return $inscomp_retval
        fi
      fi
    fi
  fi
}
###############################################################################
# Description - new_dolink - Create sybolic links from configuration
###############################################################################
function new_dolink 
{
  typeset localrc=0
  typeset linkdone=0
  linkreplace_opt=${1}
  link_ovw=${2}
  link_shr=${3}
  linktarget=${4}
  linkname=${5}
  perm=${6}
  component_uninstall=${7}
#  
  if [[ -f ${linktarget} ]]; then
    if [[ -f ${linkname} && ${link_ovw} = 1 ]]; then rm -f ${linkname}; fi
    if [[ ! -L ${linkname} ]]; then
      ln -sf ${linktarget} ${linkname}
      localrc=$?
      linkdone=1
      if [[ ${localrc} = 0 ]]; then
        chmod ${perm} ${linkname}
        localrc=$?
        if [[ ${localrc} = 0 ]]; then
          if [[ ! -z ${user} && ! -z ${group} ]]; then
            tmp=$(chown -h ${user}:${group} ${linkname} 2>>${ERR})
            if [[ ! -z ${tmp} ]]; then
              PresentMessage ERR_CHOWNERR ${linkname}
              localrc=1
            fi
          fi
        else
          PresentMessage ERR_PERMISSION $perm ${linkname}
        fi  
      else
        PresentMessage ERR_SYMLINKFAIL ${linkname} ${linktarget}
      fi
    fi
#
    if [[ ${localrc} = 0 ]]; then
#
#     for the moment, uninstall is only created when a link is actually
#     created. This logic will be adapted to accommodate links with the 
#     share flag set.
#
      if [[ ${linkdone} = 1 ]]; then
#         
#
#       create link uninstall entry. If the link is not fully
#       qualified, assume it is relative to the installation directory.
#
        if [[ "/${linkname#/}" != ${linkname} ]]; then
          linkname=${installdir}/${linkname}
        fi
#
#       If an uninstall script is provided, it is assumed to be for
#       a component. Otherwise, the uninstall entry is created for the product.
#
        if [[ ! -z ${component_uninstall} ]]; then    
          print "Remove $linkname 2>>$NUL" >> ${component_uninstall}
        else
#
#         add the link as a product uninstall entry
#
          print "rm -f $linkname 2>>$NUL" >> ${product_uninstall}
        fi
      fi
    fi
  else
#
#   The named target of the link definition does not exist. This is only
#   an error condition if the replacement option has not been specfied
#   as "IFEXIST"
#
    if [[ ! -z ${linkreplace_opt} && ${linkreplace_opt} != "IFEXIST" ]]; then
      PresentMessage ERR_LINKTARGETNF ${linktarget}
      localrc=1
    fi
  fi           
  return ${localrc}       
}
###############################################################################
# Description: Create subdirectories from passed list
###############################################################################
function do_psubdir
{
   if [ ! -z "$psubdir" ]; then
      set $psubdir
      while [ $# -gt 0 ]; do
         psub_dir=$1
         one_char=$psub_dir
         if [ "$one_char" != "/" ]; then
            psub_dir=$installdir"/"$psub_dir
         else
            return 1
         fi
         perm=$2
         if [ ! -d $psub_dir ]; then
            mkdir -m $perm -p $psub_dir
            if [ ! -d "$psub_dir" ]; then
               PresentMessage ERR_SUBDIRERR ${psub_dir}
               return 1
            else
               PresentMessage INFO_DIRCREATED ${psub_dir} ${perm}
               PresentationDelay ${sleeptime_short}
            fi
         fi
         allsubdir="$allsubdir $psub_dir"
         if [ ! -z "$user" -a ! -z "$group" ]; then
           tmp="$(chown "$user:$group" "$psub_dir" 2>>"$ERR")"
           if [ ! -z "$tmp" ]; then
             PresentMessage ERR_CHOWNERR $psub_dir
             return 1
           fi
         fi
         shift 2
      done
   fi
}
###############################################################################
# Description: set global flags for installation platform. 
#
# Note: Though these flags are used, I am not convinced they are needed.
###############################################################################
function set_osver_flag
{
 if [[ ${ostype} = "SunOS" ]]; then
      if [[ ${osver} = "29" ]]; then
         sun29=1
      elif [[ ${osver} = "28" ]]; then
         sun28=1
      elif [[ ${osver} = "27" ]]; then
         sun27=1
      elif [[ ${osver} = "26" ]]; then
         sun26=1
      elif [[ ${osver} = "25" ]]; then
         sun25=1        
      fi
 elif [[ ${ostype} = "Linux" ]]; then
      if [[ ${osver} = "24" ]]; then
        linux24=1
      fi
      noleaf=-noleaf
 elif [[ ${ostype} = "zLinux" ]]; then
      if [[ ${osver} = "26" ]]; then
        zlinux26=1
      fi
      noleaf=-noleaf                 
 elif [[ ${ostype} = "HP-UX" ]]; then
      if [[ ${osver} = "11" ]]; then
         hp11=1
      elif [[ ${osver} = "10" ]]; then
         hp10=1
      fi    
 elif [[ ${ostype} = "ITANIUM" ]]; then
      hp11i32=1
 elif [[ ${ostype} = "AIX" ]]; then
      if [[ ${osver} = "53" ]]; then
        aix53=1
      elif [[ ${osver} = "52" ]]; then
        aix52=1
      elif [[ ${osver} = "43" ]]; then
        aix51=1
      elif [[ ${osver} = "43" ]]; then
         aix43=1
      elif [[ ${osver} = "42" ]]; then
         aix42=1
      fi      
 elif [[ ${ostype} = "OSF1" ]]; then 
      if [[ ${osver} = "3" ]]; then
         dec3=1
      elif [[ ${osver} = "4" ]]; then    
         dec4=1
      fi      
 fi
}
#
function Remove_extension_file
{
 if [ "$ostype" = "SunOS" ]; then
   tmp26="$(find $installdir $noleaf -type f -name "*_26*" -print 2>>$ERR)"
   tmp27="$(find $installdir $noleaf -type f -name "*_27*" -print 2>>$ERR)"
   if [ "$platverm" = "5" ]; then
      for t in "$tmp26 $tmp27"; do
         rm $t 2>>$ERR
      done
   elif [ "$platverm" = "6" ]; then
      for t in "$tmp27"; do
         rm $t 2>>$ERR
      done
      for t in $tmp26; do
         t1="${t%/*}"
         t2="`echo $t | sed -e 's,^.*/,,g' -e 's,_26,,'`"
         mv -f $t "$t1"/$t2 2>>$ERR
         if [ $? -ne 0 ]; then
            PresentMessage ERR_MOVEERR ${t} ${t1}${t2}
            do_fail
         fi
      done
   elif [ "$platverm" = "7" -o "$platverm" = "8" -o "$platverm" = "9" ]; then
      for t in "$tmp26"; do
         rm $t 2>>$ERR
      done
      for t in $tmp27; do
         t1="${t%/*}"
         t2="`echo $t | sed -e 's,^.*/,,g' -e 's,_27,,'`"
         mv -f $t "$t1"/$t2 2>>$ERR
         if [ $? -ne 0 ]; then
            PresentMessage ERR_MOVEERR ${t} ${t1}${t2}
            do_fail
         fi
      done
   fi
   if [ ! -z "$tmp26" -o ! -z "$tmp27" ];then
   	tmp_2627="$tmp26 $tmp27"
   	if [ ! -z "$tmp_2627" ];then
   		set $tmp_2627
  	 fi
   	for t in $tmp_2627; do
         	Remove_Overwritten_Deleted_Files $t
   	done
   fi
elif [ "$ostype" = "AIX" ]; then
   tmp43="$(find $installdir $noleaf -type f -name "*_43*" -print 2>>$ERR)" 
   if (( aix42 == 1 ))
   then
      for t in "$tmp43"; do
         rm $t 2>>$ERR
      done
   elif (( aix43 == 1 ))
    then      
      for t in $tmp43; do
         t1="${t%/*}"
         t2="`echo $t | sed -e 's,^.*/,,g' -e 's,_43,,'`"
         mv -f $t "$t1"/$t2 2>>$ERR
         if [ $? -ne 0 ]; then
            PresentMessage ERR_MOVEERR ${t} ${t1}${t2}
            do_fail
         fi
      done   
   fi
   if [ ! -z "$tmp43" ];then
	set $tmp43
   	for t in $tmp43; do
         	Remove_Overwritten_Deleted_Files $t
   	done
   fi
fi
}
#
#function create_awkfile
#{
# print "{ \n\t if ( \$1 < \$2 ) { " > $sysdir/awkfile
# print "\t\t exit 1" >> $sysdir/awkfile
# print "\t } else { " >> $sysdir/awkfile
# print "\t\t exit 0 }\n}" >> $sysdir/awkfile
#}
#############################################
# Description : Process command line options
#############################################
function ProcessCmdLine
{
        typeset opt arg
        opt=$1
        arg=$2
        case $opt in
            [sS])  bInteractive="FALSE"
                   bRecording="FALSE"
                   bOptions="TRUE"
                   recordfile=${arg}
                   ;;
            [rR])  bRecording="TRUE"
                   recordfile=${arg}
                   bOptions="TRUE"
                   ;;
            [lL])  loggingfile=${arg}
                   bOptions="TRUE"
                   ;;
            :)     PresentMessage ERR_BADOPTION ${option}
                   ;;
            \\?)   PresentMessage ERR_BADOPTION ${option}
                   ;;
        esac
}
#############################################
# Description : Initialize user prompts
#############################################
function Init_promptresp {
# set tag definitions
prompt_tag[${PRODSELECT}]="PRODSELECT"
prompt_tag[${TXINSTALLDIR}]="TXINSTALLDIR"
prompt_tag[${TXTMPDIR}]="TXTMPDIR"
prompt_tag[${TXOWNUSER}]="TXOWNUSER"
prompt_tag[${TXOWNGROUP}]="TXOWNGROUP"
prompt_tag[${TXBROWSER}]="TXBROWSER"
# set default responses
prompt_resp[${PRODSELECT}]="ALL"
# 
# Installation directory varies with AIX platform
#
#if [[ ${ostype} = "AIX" ]]; then
  prompt_resp[${TXINSTALLDIR}]="/opt/ibm/wsdtx"
#else
#  prompt_resp[${TXINSTALLDIR}]="/var/ibm/wsdtx"
#fi
prompt_resp[${TXTMPDIR}]="/tmp"
prompt_resp[${TXOWNUSER}]="user"
prompt_resp[${TXOWNGROUP}]="group"
prompt_resp[${TXBROWSER}]="/usr/netscape"
# set prompt descriptions
prompt_desc[${PRODSELECT}]=$(grep REC_PRDSEL: ${msg_file})
prompt_desc[${TXINSTALLDIR}]=$(grep REC_PRDINSDIR: ${msg_file})
prompt_desc[${TXTMPDIR}]=$(grep REC_PRDWKRDIR: ${msg_file})
prompt_desc[${TXOWNUSER}]=$(grep REC_PRDOWN: ${msg_file})
prompt_desc[${TXOWNGROUP}]=$(grep REC_PRDGRP: ${msg_file})
prompt_desc[${TXBROWSER}]=$(grep REC_BRWPATH: ${msg_file})
#
prompt_desc[${PRODSELECT}]=${prompt_desc[${PRODSELECT}]#REC_PRDSEL:}
prompt_desc[${TXINSTALLDIR}]=${prompt_desc[${TXINSTALLDIR}]#REC_PRDINSDIR:}
prompt_desc[${TXTMPDIR}]=${prompt_desc[${TXTMPDIR}]#REC_PRDWKRDIR:}
prompt_desc[${TXOWNUSER}]=${prompt_desc[${TXOWNUSER}]#REC_PRDOWN:}
prompt_desc[${TXOWNGROUP}]=${prompt_desc[${TXOWNGROUP}]#REC_PRDGRP:}
prompt_desc[${TXBROWSER}]=${prompt_desc[${TXBROWSER}]#REC_BRWPATH:}
#
# perform any adustments to the defaults
#
if [[ ( ! -z ${TMPDIR} ) &&  -d ${TMPDIR} && -w ${TMPDIR} ]]; then
  prompt_resp[${TXTMPDIR}]=$TMPDIR
elif [[ ( ! -z ${TMP} ) && -d "$TMP" && -w "$TMP" ]]; then
  prompt_resp[${TXTMPDIR}]=$TMP
fi
}
##################################################################
# Description - ReadInstallFile - retrieve recorded installation 
#               information
##################################################################
function ReadInstallFile {
  typeset -i ArrayIndex=0
#        
  exec 5< ${recordfile}
  while read -u5 line; do
    if [ "$line" = "" ]; then
      continue
    fi
    oldifs=${IFS}
    IFS=":"
    set $line
    IFS=${oldifs}
    one_char=$1
    if [ "$one_char" = "#" ]; then
      continue
    fi
    if [ $# -lt 2 ]; then
      PresentMessage ERR_BADRECLINE ${recordfile}
      PresentMessage ERR_BADLINECONTENT ${line}
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    fi         
    tag=$1
    val=$2
#
#   look for the specified tag in the prompt array. If a matching entry
#   is found, set the corrosponding prompt entry
#
    ArrayIndex=0
    while [[ ${ArrayIndex} -le ${TXMAXPROMPT} ]]; do
      if [[ ${tag} = ${prompt_tag[${ArrayIndex}]} ]]; then
        prompt_resp[${ArrayIndex}]=${val}
        break
      else
        ArrayIndex=$(( ${ArrayIndex} + 1 ))
      fi
    done
    if [[ ${ArrayIndex} -gt ${TXMAXPROMPT} ]]; then
      PresentMessage ERR_RECBADTAG ${tag} ${recordfile}
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    fi
  done
  exec 5<&-
}
##################################################################
# Description - DisplayMessage - Put a message out to the display
#               and optionally the run and error logs.
##################################################################
function DisplayMessage {
typeset -i msg_class
#
msg_class=${1}
shift 1

print "$*" 
if [[ ! -z ${loggingfile} ]]; then
  if [[ ! -f ${loggingfile} ]]; then
    touch ${loggingfile} > /dev/null 2>&1
  fi
  if [[ -f ${loggingfile} ]]; then  
    print "$*" >> ${loggingfile}
  fi
fi 
if [[ ${msg_class} -ge ${MSG_ERR} ]]; then
  if [[ ! -z ${ERR} ]]; then
    print "$*" >> ${ERR}
  fi
fi
}
##################################################################
# Description - PresentMessage - Retrieve locale specific messages
#               for user presentation.
##################################################################
function PresentMessage {
#
  typeset -i argcount
  typeset -i index
  set -A strings
#
# if at least one argument was passed, and the message file is 
# available, attempt message presentation
#
  if [[ $# -gt 0 ]]; then
    if [[ -f ${msg_file} ]]; then
#
#     retrieve arguments for message substitution. These
#     are always extracted so that they are not lost
#
      msgcode=$1
      shift 1
      argcount=$#
      index=0
      while [[ ${index} -lt ${argcount} ]]; do
        strings[${#strings[*]}]=${1}
        shift 1
        index=$(( ${index} + 1 ))
      done
#
#     look for the requested message
#      
      msgcode="${msgcode}:"
      msg=$(grep ${msgcode} ${msg_file})
#
#     if the message was located, continue examination of 
#     the message text. Otherwise, report the error.
#
      if [[ $? = 0 ]]; then
        msg=${msg##${msgcode}}
#      
#       Positional substitution is only attempted when arguments have
#       been provided.
#        
        if [[ ${#strings[*]} -gt 0 ]]; then
#
          index=0
#
#         If an "all arguments" tag is present, Rebuild the passed
#         string and insert it into the retrieved message. Otherwise,
#         single argument replacement is attempted.
#
          print -r ${msg} | grep %@% > /dev/null 2>&1 
          if [[ $? = 0 ]]; then
#
#           The entire argument string should be substituted. 
#           The passed argument string is reconstructed and the 
#           substitution performed.
#
#
            msgtext=""
            while [[ ${index} -lt ${argcount} ]]; do
              msgtext="${msgtext} ${strings[${index}]}"
              index=$(( ${index} + 1 ))
            done
            msg=$(print -r ${msg} | sed "s|%@%|${msgtext}|g")
          else
# 
#           Passed arguments are considered for substitution if there
#           is a corrosponding tag.
#           Note: the substitution tags are relative 1 and the array
#           index is relative 0
#
            while [[ ${index} -lt ${argcount} ]]; do
              tag_num=$(( ${index} + 1 ))
              print -r ${msg} | grep %${tag_num}% > /dev/null 2>&1
              if [[ $? = 0 ]]; then
#
#               an argument corrosponding tag exists
#
                msg=$(print -r ${msg} | sed "s|%${tag_num}%|${strings[${index}]}|g")
                index=$(( ${index} + 1 ))
              else
                break
              fi
            done
#
#           all the numbered tags should have been replaced. If there are 
#           remaining arguments, look for the "remainder" tag %+%. If it is
#           present in the message, replace it with the remaining arguments
#
            if [[ ${index} -lt ${argcount} ]]; then
              print -r ${msg} | grep %+% > /dev/null 2>&1
              if [[ $? = 0 ]]; then
                msgtext=""
                while [[ ${index} -lt ${argcount} ]]; do
                  msgtext="${msgtext} ${strings[${index}]}"
                  index=$(( ${index} + 1 ))
                done
                msg=$(print -r ${msg} | sed "s|%+%|${msgtext}|g")
              fi
            fi              
          fi
        fi
#  
      else
        msg="Messsage tag ${msgcode%:} not found in the message file ${msg_file}"
      fi
    else
      msg="Messsage file ${msg_file} cannot be located"
    fi
  else
    msg="Improper call to the message function. Message tag is required"
  fi
#
# Display any message 
#
  if [[ ! -z ${msg} ]]; then
#
#   Message class is determined by the message tag. If the tag begins with "ERR_" it
#   is considered an error message.
#
    msg_class=${MSG_INFO}
    if [[ "ERR_${msgcode#ERR_}" = ${msgcode} ]]; then
      msg_class=${MSG_ERR}  
    fi
    DisplayMessage ${msg_class} ${msg}
  fi
}
##################################################################
# Description - GetResponseInfo - Retrieve response information
#               from the provided recorded install information
##################################################################
function GetResponseInfo {
typeset -i resp_num
#
resp_num=${1}
if [[ ${resp_num} -ge 0 && ${resp_num} -le ${TXMAXPROMPT} ]]; then
  print "${prompt_resp[${resp_num}]}"
else
  PresentMessage ERR_REPONSEOOR ${resp_num} ${TXMAXPROMPT}
  PresentMessage ERR_SUPPORTINFO ${CompanyName}
  do_fail
fi
}
####################################################################
# Description - SaveResponseInfo - Save provided reponse information
#                                  for later use
##################################################################
function SaveResponseInfo {
typeset -i resp_num
#
resp_num=${1}
shift 1
if [[ ${resp_num} -ge 0 && ${resp_num} -le ${TXMAXPROMPT} ]]; then
  prompt_resp[${resp_num}]="$*"
else
  PresentMessage ERR_REPONSEOOR ${resp_num} ${TXMAXPROMPT}
  PresentMessage ERR_SUPPORTINFO ${CompanyName}
  do_fail
fi
}
####################################################################
# Description - PromptInstall - Return install information
##################################################################
function PromptInstall {
typeset -i prompt_num
#
prompt_num=${1}
shift 1
prompt_response=""
if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]]; then
  prompt_response="$(GetResponseInfo ${prompt_num})"
else
  read prompt_response
fi  
if [[ ! -z ${prompt_response} ]]; then
  SaveResponseInfo ${prompt_num} ${prompt_response}
fi
}
####################################################################
# Description - Determine current locale for Presentation management
####################################################################
function set_locale_name {
#
# Determine the current locale. "en" is used for the default.
# 
#  typeset -l locname=""
#  typeset -l tmplocname=""
#  tmplocname=$(locale | grep -i "Lang")
#  locname=$tmplocname
#  locname=${locname##lang=}
#  locname=${locname%%_*}
#  locname=${locname##*_}
#  if [[ -z ${locname} ]]; then
#    locale_name="en"
#  else
#   case $locname in
#     "en"|"ja"|"ko"|"fr"|"de"|"it"|"es") locale_name=${locname};;
#     "zh")
#       locname=$(echo $tmplocname | grep -i "zh_CN")
#       if [[ -z  ${locname} ]]; then
#         locname=$(echo $tmplocname | grep -i "zh_TW")
#         if [[ -z  ${locname} ]]; then
#           localname="en"
#         else
#           locname="zh_TW"
#         fi
#       else
#         locname="zh_CN"
#       fi
#       locale_name=$locname
#     ;;
#     "pt")
#       locname=$(echo $tmplocname | grep -i "pt_BR")
#       if [[ -z  ${locname} ]]; then
#         locname="en"
#       else
#         locname="pt_BR"
#       fi
#       locale_name=$locname
#     ;;
#     *) locale_name="en";;
#   esac
#  fi
#
# For Bluehawk 8.1.0.0, only english locale is supported 
#
  locale_name="en"
#
}
#####################################################################
# SaveConfiguration - Retain existing configuration files
#####################################################################
function SaveConfiguration 
{
#
# Only save files once!
#
  if [[ ${config_found} = 0 ]]; then
#
#   insure config file save area exists
#  
    configspace="${tmp_instdir}/savedconfiguration"
    if [[ ! -d ${configspace} ]]; then mkdir ${configspace}; fi
#
#   retain a copy of each identified config file
#

    PresentMessage INFO_SAVINGCONFIG
#    
    cur_cfgfile=0   
    while [[ ${cur_cfgfile} -lt ${#config_files[*]} ]]; do
      cfgfile=${config_files[${cur_cfgfile}]}
      tmp_ifs=${IFS}
      IFS=":"
      set ${cfgfile}
      cfgf_dir=${1}
      cfgfile=${2}
      IFS=${tmp_ifs}
#      
      if [[ ${cfgf_dir} = "INSTROOT" ]]; then
        cfgfile="${installdir}/${cfgfile}"
      else
        cfgfile="${installdir}/${cfgf_dir}/${cfgfile}"      
      fi
#
#     Only actual files (not links) are retained
#
      if [[ -f ${cfgfile} && ! -L ${cfgfile} ]]; then
        cp -p ${cfgfile} ${configspace} 2>> $ERR
        rc=$?
#
#       If the copy was successful, mark config files saved. 
#       Otherwise, report the copy error.
#
        if [[ ${rc} = 0 ]]; then
          config_found=1            
        else
          PresentMessage ERR_COPYERR ${cfgfile} ${configspace}
        fi
      fi
      cur_cfgfile=$(( ${cur_cfgfile} + 1 ))      
    done
  fi
}
#####################################################################
# RestoreConfiguration - Restore prior existing configuration files
#####################################################################
function RestoreConfiguration
{
  configspace="${tmp_instdir}/savedconfiguration"
#
# process saved configuration files if any were found during the install
#  
  if [[ ${config_found} = 1 && -d ${configspace} ]]; then
#
#   process each defined configuration file that may have been retained.
#     
    PresentMessage INFO_RESTORECONFIG
#    
    cur_cfgfile=0   
    while [[ ${cur_cfgfile} -lt ${#config_files[*]} ]]; do
      cfgfile=${config_files[${cur_cfgfile}]}
      tmp_ifs=${IFS}
      IFS=":"
      set ${cfgfile}
      cfgf_dir=${1}
      cfgfile=${2}
      IFS=${tmp_ifs}
#      
      if [[ ${cfgf_dir} = "INSTROOT" ]]; then
        trgtcfgfile="${installdir}/${cfgfile}"
      else
        trgtcfgfile="${installdir}/${cfgf_dir}/${cfgfile}"
      fi
      cfgfile="${configspace}/${cfgfile}"
#
#     if the configuration file has been retained, check it for 
#     retention.
#
      if [[ -f ${cfgfile} ]]; then
      
#
#       if the configuration file exists and does not match the
#       retained configuration file, it is assumed to have been placed by
#       the installation. In this case, the new configuration file is 
#       renamed.
#
        if [[ -f ${trgtcfgfile} ]]; then
          cmp ${trgtcfgfile} ${cfgfile} 1>> ${ERR} 2>&1
          if [[ $? != 0 ]]; then
            mv ${trgtcfgfile} ${trgtcfgfile}_${release_version} 2>> ${ERR}
            if [[ $? != 0 ]]; then
              PresentMessage ERR_MOVEERR ${trgtcfgfile} ${trgtcfgfile}_${release_version}
            else
              print "rm -f ${trgtcfgfile}_${release_version} 2>>$NUL" >> "$product_uninstall"
            fi
          fi
        fi
#
#       restore the saved configuration file
#
        cp -p ${cfgfile} ${trgtcfgfile} 2>> ${ERR}
        if [[ $? != 0 ]]; then
          PresentMessage ERR_COPYERR ${cfgfile} ${trgtcfgfile}
        fi
      fi
      cur_cfgfile=$(( ${cur_cfgfile} + 1 ))
    done
  fi
}
####################################################################
# Description - PresentationDelay - Provided delay in presentation 
#               update for user recognition
##################################################################
function PresentationDelay {
  typeset -i DelayTime
#
  DelayTime=${1}
#
# do not delay if operating unattended
#
  if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]]; then
    DelayTime=0
  fi
#
# if any delay time has been specified, sleep for the specified time
#
  if [[ ! -z ${DelayTime} && ${DelayTime} != 0 ]]; then
    sleep ${DelayTime}
  fi 
#
}
###############################################################################
###############################################################################
###############################################################################
###############################################################################
###############################################################################
#MAIN/main PROGRAM
#
#GLOBAL VARIABLES
typeset -i inst_returncode=0
bInteractive=TRUE
bRecording=FALSE
bOptions=FALSE
recordfile=""
loggingfile=""
set -A prompt_resp
set -A prompt_tag
set -A prompt_desc
set -A Def_links
#
# user message constants
#
MSG_INFO=0
MSG_ERR=1
#
# User interface control
#
typeset sleeptime_short=1
typeset sleeptime_long=2
#
typeset locale_name="en"
export locale_name
set_locale_name
msgfile_path=${0}
progname=${msgfile_path##*/}
if [[ ${msgfile_path} = ${progname} ]]; then
  msgfile_path=$(pwd)
else
  msgfile_path=${msgfile_path%/${progname}*}
fi
msgfile_path="${msgfile_path}/messages"
#
# If the message file path is not fully qualified, it must be relative to 
# our location. In this case, the attempt is made to determine the exact 
# location of the message file
#
if [[ "/${msgfile_path#/}" != ${msgfile_path} ]]; then
 current_location=$(pwd)
 msgfile_path=${current_location}/${msgfile_path}
 cd ${msgfile_path}
 msgfile_path=$(pwd)
 cd ${current_location}
fi
msg_filename="${locale_name}_msg.txt"
msg_file="${msgfile_path}/${msg_filename}"
if [[ ! -f ${msg_file} ]]; then
  msg_filename="en_msg.txt"
  msg_file="${msgfile_path}/${msg_filename}"
  if [[ ! -f ${msg_file} ]]; then
    DisplayMessage ${MSG_ERR} "No message file can be located. Install will terminate..."    
    DisplayMessage ${MSG_ERR} "${tsisupport}"
    get_out
  else
#
#  Note: The following must remain print statements as to not overwrite any
#  passed option strings
#  
    print "Error - Only the english message file can be located. Messages cannot be localized."
  fi  
fi
license_file="${msgfile_path}/license/LA_${locale_name}.txt"
#
prompt_response=""
#
while getopts "s:S:r:R:l:L" option; do
  ProcessCmdLine ${option} ${OPTARG}
done
#
# Some constants
# Prompt Array fields:
#
PROMPTTAG=0
PROMPTRESP=1
PROMPTELEMS=2 # number of array elements to account for
#
# Prompt Sequence Number:
#
PRODSELECT=0
TXINSTALLDIR=1
TXTMPDIR=2
TXOWNUSER=3
TXOWNGROUP=4
TXBROWSER=5
TXMAXPROMPT=5
#
# Platform flags (these may not really be necessary) 
#
typeset -i sun25=0
typeset -i sun26=0
typeset -i sun27=0
typeset -i sun28=0
typeset -i sun29=0
typeset -i aix42=0
typeset -i aix43=0
typeset -i aix51=0
typeset -i aix52=0
typeset -i aix53=0
typeset -i linux24=0
typeset -i zlinux26=0
typeset -i hp10=0
typeset -i hp11=0
typeset -i hp11i32=0
#
typeset -L1 one_char
typeset -i compnum=0
typeset -i valnum
typeset -i packnum=0
typeset -i pn
typeset -i compindex
typeset -i arraysize=16
typeset -i linenum
typeset -i retval
typeset -i install_good=0
typeset -i install_fail=0
typeset -i install_notselect=0
typeset -i install_error=0
typeset -i lena
typeset -i lenp
typeset -i tmpnum
typeset -i numprods
typeset -i ix_component=0
typeset -i ix_compfile=1
typeset -i ix_compver=2
typeset -i ix_composver=3
typeset -i ix_compname=4
typeset -i ix_compdesc=5
typeset -i ix_comptarfile=6
typeset -i ix_compos=7
typeset -i ix_nvalid=8
typeset -i ix_product_name=9
typeset -i ix_package_name=10
typeset -i ix_package_desc=11
typeset -i ix_select=12
typeset -i ix_overwrite=13
typeset -i ix_curinstall=14
typeset -i ix_visible=15
typeset -i prereqnum=0
typeset -u replyuc
typeset -i flag=0
typeset -i printflag=0
typeset -i jdkflag=0
typeset -i jdk11=0
typeset -i jdk12=0
typeset -i selectflag=0
#typeset -i allflag=0
typeset -i oracleflag=0
typeset -i oracle7=0
typeset -i oracle8=0
typeset -i mqseriesflag=0
typeset -i mqseries=0
typeset -i mqseriesC=0
typeset -i mqseries_loop=0
typeset -i mqseriesC_loop=0
typeset -i countflag=0
noleaf=
typeset -i mutualExComp=0
typeset sosl
typeset -i SPACE
typeset -i install_space=0
typeset -i num_comp=0
typeset -i shared_plat=0
typeset -i nonthr_chosen
typeset current_user
common=.List
file_tmp=.file_tmp
typeset found_product
typeset Exclude_EA=0
typeset list_of_uninstalls
typeset -i sub_oslevel=0
typeset -i int_platverm=0
#
typeset flag_for_setup=0
typeset files_in_libs
product_reinstall="no"
typeset -i Total_Selected_Components=0
typeset -i Total_Shared_Components=0
typeset -u answer_of_ques
launcher_to_uninstall="0"
engine_to_uninstall="0"
typeset -u inst_type
#
osver=""
#
# Message Broker install variables
#
WMB_Found=FALSE					     # mqsi v6 installed?
WBI_V6x_SHAREDROOT="/var/mqsi"	                     # mqsi v6 profiles directory path
WBI_V6x_SHAREDCOMMON="${WBI_V6x_SHAREDROOT}/common"  # mqsi v6 profiles directory path
WBI_V6x_PROPATH="${WBI_V6x_SHAREDCOMMON}/profiles"   # mqsi v6 profiles directory path
MQSI_FILEROOT="dtxwmqi"                         # file name for Message Broker integration
#
# WESB variables
#
set -A WPS_Installs
#
WPS_Found="FALSE"   				     # Process Server installed?
typeset nifreg=".nif/.nifregistry"
typeset WPS_ID="WBI"
typeset WESB_ID="ESB"
typeset MIN_ESB_VER="6.1.X.X"
typeset BundleName="com.ibm.wtx.runtime_8.2.0.jar"
#
IAMROOT=FALSE					# flag set when installer is root
inst_libpathname=""		# shared library path name
use_ibmjava=0                   # set to indicate a jre has been installed
#
# The following addresses preexisting configuration files found
# during a re-install. The table contains files which will be examined
# and if they are found to exist as files, they will be retained.
# Each table entry consists of colon separated pairs of 
# directory:file name entries. Additional files to be retained should
# be added as elements of this table.
# The special directory name INSTROOT is used to signify the root of 
# the installation directory.
#
set -A config_files
config_files[0]="config:adapters.xml"
config_files[1]="config:dtx.ini"
config_files[2]="config:dstx.ini"
config_files[3]="config:mercator.ini"
config_files[4]="wmqi:dtxwmqi.ini"
config_files[5]="INSTROOT:LauncherAdmin.bin"
config_files[6]="INSTROOT:EventServerAdmin.bin"
config_files[7]="INSTROOT:mgmtconsole.bin"
config_files[8]="wmqi:dstxwmqi.ini"
#
typeset config_file_count=${#config_files[*]}
typeset config_found=0
typeset release_version="8.2.0.2"
#
typeset Package_Wordsize=""
typeset Component_Wordsize=""
#
# Start of code. 
trap 'terminate' 1 2 3 15
#
ostype="$(uname)"
#
# adjust ostype for itanium (if applicable)
#
if [[ ${ostype} = "HP-UX" ]]; then
  if [[ $(uname -m) = "ia64" ]]; then
    ostype="ITANIUM"
  fi
#
# check for zLinux
#
elif [[ ${ostype} = "Linux" ]]; then
  tmp=$(uname -m)
  if [[ ${tmp} = "s390${tmp#s390}" ]]; then
    ostype="zLinux"
  fi
fi
#
if [ -z "$PWD" ];then
	curdir="$(pwd)"
else
	curdir=$PWD
fi
pgm=$0
typeset -fu SELECT_COMP
find_path="${pgm%DTXINST*}"
if [ ! -z "$find_path" ];then
	cd $find_path
	if [ $? -ne 0 ]; then
   	  PresentMessage ERR_BADCD $find_path
          PresentMessage PROMPT_CHKDIR $find_path
   	  do_fail
	fi
	if [ ! -f "$(pwd)/SELECT_COMP" ];then
		PresentMessage ERR_CRITICALFILEMISSING $(pwd)/SELECT_COMP
		PresentMessage INFO_INSTALLTERM
		do_fail
	fi		
fi
FPATH="$(pwd)":$curdir
cd - > /dev/null 2>&1	
pgmname=dtxinst

if [ "$ostype" = "Windows_NT" ]
then
   NUL="/tmp/results"
else
   NUL="/dev/null"
fi
get_os_version
set_defaults
#
do_clear_screen
#
# TR 9811-9812
if [ "$ostype""$osver" = "AIX42" -o "$ostype""$osver" = "AIX43" -o "$ostype""$osver" = "HP-UX10" ];then
	PresentMessage ERR_NOSUPPORT $ostype $osver
	PresentMessage ERR_SUPPORTINFO ${CompanyName} 
	do_fail
fi
#
# verify any provided options
#
if [[ ${bOptions} = "TRUE" ]]; then
#
# if recording, can not be playing back
#
  if [[ ${bRecording} = "TRUE" ]]; then
    bInteractive="TRUE"
    if [[ -z ${recordfile} ]]; then
      PresentMessage ERR_NORECFILE
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    else
      if [[ -z ${loggingfile} ]]; then
        loggingfile="${recordfile}.log"
      fi
    fi
  else
#
#  not recording, check for silent installation
#
    if [[ ${bInteractive} = "FALSE" ]]; then
      bRecording=FALSE
      if [[ ! -f ${recordfile} ]]; then
        PresentMessage ERR_NOPLAYBACKFILE ${recordfile} 
        do_fail
      else
        if [[ -z ${loggingfile} ]]; then
          loggingfile="${recordfile}.log"
        fi
#
        ReadInstallFile
#
      fi    
    fi  
  fi
#
# insure the logging file is fully qualified. If the log file cannot be
# written, report the error and disable logging.
#
  if [[ ${loggingfile} = ${loggingfile##*/} ]]; then
#   
#   just a file name was determined. use the current directory 
#   for the log.
#
    loggingfile="$(pwd)/${loggingfile}"
  fi
  if [[ ! -z ${loggingfile} ]]; then
    touch ${loggingfile} 2> /dev/null
    if [[ $? != 0 ]]; then
      logfilename="${loggingfile}"
      loggingfile=""
      unset logmessage
      PresentMessage ERR_CANTLOG ${logfilename}
      unset logfilename
    else
      PresentMessage INFO_INSTALLOGGING ${loggingfile}
    fi
  fi
else
#
# no supported options are presented. If there is an argument present, assume it is 
# a provided installation path
#
  installdir=$1
  insttmpdir=$2
  locdir=$3
  if [[ ! -z ${installdir} ]]; then
#
#   insure the parent of the specified directory exists.
#
    typeset zdir
    zdir=${installdir%/}
    zdir=${zdir%/*}
    if [[ ! -d ${zdir} ]]; then
      PresentMessage ERR_INSTDIRINV ${zdir}
      PresentMessage INFO_DIRIGNORED
    else
      prompt_resp[${TXINSTALLDIR}]=${installdir%/}  
    fi
    unset zdir
  fi
#  
  if [[ ! -z ${insttmpdir} ]]; then
#
#   insure the specified directory exists.
#
    if [[ ! -d ${insttmpdir} ]]; then
      PresentMessage ERR_WRKDIRINV ${insttmpdir}
      PresentMessage INFO_DIRIGNORED
    else
      prompt_resp[${TXTMPDIR}]=${insttmpdir}  
    fi
    unset insttmpdir
  fi
fi
#
if [[ -z ${locdir} ]]; then
  locdir="$(whence $pgm)"
  pgm="${locdir##*/}"
  locdir="${locdir%%/$pgm}"
fi
chk_dir $locdir
locdir=$chk_dir_dir"/"
if [[ ! -d "$locdir" ]]; then
  PresentMessage ERR_NOTVALDIR $locdir
  do_fail 
fi  
#
PresentMessage INFO_ALLTERMS ${dtxinst_ver}
PresentMessage INFO_IBMCOPYWRIGHT
PresentMessage INFO_ASCLCOPYWRIGHT
PresentMessage INFO_TERMMSG
wait_for_enter
if [[ ! -f ${license_file} ]]; then license_file="$locdir""LICENSE.TXT" ; fi
if [ -s ${license_file} -a ${bInteractive} = "TRUE" ]; then
   replyuc=""
   while [ "$replyuc" != "YES" -a "$replyuc" != "NO" ]; do
      cat $locdir"LICENSE.TXT" | more
#
      hdr_underline 90 '*'
      PresentMessage PROMPT_LIC1
      PresentMessage PROMPT_LIC2
      PresentMessage PROMPT_LIC3
      read replyuc
   done
   if [ "$replyuc" = "NO" ]; then
      PresentMessage PROMPT__REMOVESW
      exit 0
   fi
fi
#
# errors detected are discarded until the temp directory is established.
#
export ERR=/dev/null
mk_tmp_instdir
PresentationDelay ${sleeptime_short}
error_log="$tmp_instdir/$pgmname.err"
export ERR=$error_log
do_clear_screen
get_prod
#
#Added 09/14/00 for more than 1 readme files
typeset -i Read_flag=0
typeset readme_x
for a in "README.TXT" "README_SDK.TXT" "README_WBI.TXT" "README_IS.TXT"; do

  if [ "$Read_flag" -eq 0 ];then
   if [ -s "$locdir$a" ]; then
      readme=$locdir$a
      Read_flag=1
   fi
  else
  	if [ -s "$locdir$a" ]; then
  		readme_x="$readme_x $a"
  	fi
  fi
done
info="$(head -n 1 "$locdir$infofile" 2>>"$ERR")"
Total_Lines="$(cat "$locdir$infofile" | wc -l)"
if [  "$ostype" = "HP-UX"  -o ${ostype} = "ITANIUM" ];then
	space_required="$(grep "Total_Space" "$locdir$infofile" 2>>"$ERR")"
else
	space_required="$(grep "Total_Space" "$locdir$infofile" 2>>"$ERR")"
fi
if [ -z "$info" ]; then 
   PresentMessage ERR_FNF $infofile
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi
if [ -z "$space_required" ]; then
   PresentMessage ERR_BADSPACENEEDCHECK $infofile 
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi

set $info
info_prod=$1
shift
info_ver=$1
shift
info_desc=$@
set $space_required
#
# Insure this product has been created for the installation platform
#
if [[ ${4} = ${ostype} ]]; then
  if [ "$ostype" = "HP-UX" -o ${ostype} = "ITANIUM" ];then
    if [ "$5" = "$osver" ];then
      SPACE=$2
    elif [ "${10}" = "$osver" ];then
      SPACE=$7		
    fi
  else
    SPACE=$2
  fi
else
  PresentMessage ERR_WRONGINFOFILE ${infofile} ${4} ${ostype}
  PresentMessage ERR_SUPPORTINFO ${CompanyName}
  do_fail
fi
#
#typeset -i space_of_tmpdir
if [ "$ostype" = "SunOS" -o "$ostype" = "AIX" -o "$ostype" = "OSF1" ];then
	space_in_tmpdir="$(df -k $tmp_instdir | tail -1 2>>"$ERR")"
elif  [ "$ostype" = "HP-UX" -o ${ostype} = "ITANIUM" ];then
	space_in_tmpdir="$(df -k $tmp_instdir | grep free 2>>"$ERR")"
elif [ ${ostype} = "Linux" -o ${ostype} = "zLinux" ]; then
  space_in_tmpdir="$(df -k -P $tmp_instdir | tail -1 2>>"$ERR")"
fi

if [ -z "$space_in_tmpdir" ];then
	PresentMessage ERR_BADSPACECHECK $tmp_instdir
        do_fail
else
        set $space_in_tmpdir
fi

if [ "$ostype" = "SunOS" ];then
        space_of_tmpdir=${4}
elif [ "$ostype" = "AIX" ];then
        space_of_tmpdir=${3}
elif [ "$ostype" = "Linux" -o ${ostype} = "zLinux" ];then
        space_of_tmpdir=${4}
elif [ "$ostype" = "OSF1" ];then
        space_of_tmpdir=${4}
elif [ "$ostype" = "HP-UX" -o ${ostype} = "ITANIUM" ];then
        space_of_tmpdir=${1}
fi

if [ "$space_of_tmpdir" -gt "$SPACE" ];then
	:
else
	PresentMessage ERR_NOTENOUGHSPACE
	do_fail
fi
	
do_clear_screen
if [ ! -z "$info_desc" ]; then
   DisplayMessage ${MSG_INFO} "\n***** $info_desc, ver. $info_ver *****"
fi
set_osver_flag   
PresentMessage INFO_OSDISPLAY $ostype
PresentMessage INFO_OSVERDISPLAY $osver
if [ -z "$instfile" ]; then
   if [ ! -s "$instfile" ]; then
      PresentMessage ERR_TARNOTFOUND $instfile
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
   fi
   prodfile="DTX_Product_File"
fi
instfile=${instfile##/*}
instfile1="${instfile%%.*}"".TAR.Z"
#
"cp" "$locdir$instfile"  "$tmp_instdir/" 2>> "$ERR"
if [ $? -ne 0 ]; then
   PresentMessage ERR_COPYERR $locdir$instfile $tmp_instdir
   PresentMessage INFO_CHKPERMS
   do_fail
fi

"cd" "$tmp_instdir" 2>>"$ERR"
if [ $? -ne 0 ]; then
   PresentMessage ERR_BADCD $tmp_instdir
   do_fail
fi
if [ ! -s "$instfile" ]; then
   PresentMessage ERR_COPYERR installation_files $tmp_instdir
   PresentMessage INFO_CHKPERMS
   do_fail
fi
#
# copy message file to temporary directory for local file system access
#
cp ${msg_file} ${tmp_instdir}/${msg_filename}
msg_file="${tmp_instdir}/${msg_filename}"
#
do_key
chmod 755 "$tmp_instdir"/$instfile 2>> "$ERR"
PresentMessage INFO_EXTRACTINST $decry_file
#tar -xf "$instfile" 2>> "$ERR"
tar -xf "$decry_file" 2>> "$ERR"
if [ $? -ne 0 ]; then
   PresentMessage ERR_INSTEXTRACTERR $decry_file
   PresentMessage INFO_CHKPERMS
   do_fail
fi
rm -f $instfile 2>> "$ERR"
PresentMessage INFO_UNCOMPRESS $instfile
uncompress -vf $instfile 2>> "$ERR"
rc=$?
if [[ ${rc} -gt 0 ]]; then
   PresentMessage ERR_UNCOMPRESSERR $instfile ${rc}
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi
#
authorize
#
PresentMessage INFO_EXTRACTINGTAR $instfile
tar -xf "$instfile" 2>> "$ERR"
if [ $? -gt 0 ]; then
   PresentMessage ERR_EXTRACTERR $instfile
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi
if [ ! -s "$prodfile" ]; then
   PresentMessage ERR_NOPRODFILE $prodfile
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi
PresentMessage INFO_FILESEXTRACTED
rm -f "$instfile" 2>> "$ERR"
PresentationDelay ${sleeptime_long}
read_prod
#
# provide package word size default
#
Package_Wordsize=${Package_Wordsize:-32}
#
display_prod
if [ -z "$product_name" ]; then
   PresentMessage ERR_NOPRODNAME $prodfile 
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi
if [ $compnum -eq 0 -o $valnum -eq 0 ]; then
   PresentMessage ERR_NOCOMPS
   PresentMessage ERR_SUPPORTINFO ${CompanyName}
   do_fail
fi
yes_no 1 PROMPT_CONTINUEINST $product_desc
if [[ $? = 0 ]]; then
  PresentMessage INFO_INSTTERM
  get_out
fi
if [ "$ostype" != "Windows_NT" ]; then
  get_user
#
  if [[ ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Message_Broker" || \
        ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Integration_Servers" ]]; then
#
#   If the installer is not executing as root, give them the option of quitting, as the install 
#   will likely fail.
#
    if [[ -z ${IAMROOT} || ${IAMROOT} != "TRUE" ]]; then
#
#     WTX00002235:Use proper effective user for root installation recommendation.
# 
      find_user
#
#     Note: a return of "1" indicates "root" is performing the install. 
#     The following is in place to avoid reporting root must be root. This
#     issue should never happen since IAMROOT should already be set.
#
      if [[ $? != 1 ]]; then
        yes_no 1 PROMPT_TRYASROOT ${current_user} ${product_desc}
#
#       WTX00002237:Exit if user decides not to continue installation.
#
        if [[ $? = 0 ]]; then
          PresentMessage INFO_INSTTERM
          inst_returncode=100
          get_out
        fi
      fi
    fi
#
#   Do install requisite check
#
# WTXNONE: Remove WebSphere Message Broker Integration
# WTX00026036 - Restore WebSphere Message Broker integration
#               to integration Server delivery
#
    check_wmqi_prereq
#
    check_wesb_prereq
#
#   Insure installation prerequisites have been met
#
    if [[ ${WPS_Found} = "FALSE" && ${WMB_Found} = "FALSE" ]]; then
#    
#     Installation prerequisites have not been met.
#     
      PresentMessage ERR_NOWSMBFOUND
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
    fi
  fi
else
  PresentMessage ERR_NOTONWIN 
  PresentMessage INFO_INSTTERM
  PresentMessage ERR_SUPPORTINFO ${CompanyName}
  do_fail
fi
#
# The following will actually be the test for core vs. symbiot install 
#
mloop="1"
while [ "$mloop" -eq 1 ]; do
   if [ "$info_prod" != "$oap" ]; then      
      mk_installdir
      get_sysdir
      chk_prod_exist
      if [ $? -eq 0 ]; then
         tmp="$(find $installdir $noleaf -type d -name $tmp_instdir1 -print 2>>$ERR)"
         if [ -z "$tmp" ]; then
           mloop="0"
         else
           PresentMessage ERR_TMPINWORK $tmp_instdir $installdir
           PresentMessage INFO_INSTTERM
           mloop="0"
           get_out
         fi
      else
        installdir=""
#
#       WTX00026153 - Do not revert to default directory if one has
#                     been provided.
#
        if [[ -z ${prompt_resp[${TXINSTALLDIR}]} || \
              ${prompt_resp[${TXINSTALLDIR}]} = "" ]]; then
          prompt_resp[${TXINSTALLDIR}]="/opt/ibm/wsdtx"
        fi
#
      fi
   else
      get_installdir
      if [ -z "$tmp" ]; then
         tmp="$(find $installdir $noleaf -type d -name $tmp_instdir1 -print 2>>$ERR)"
         if [ -z "$tmp" ]; then
            mloop="0"
         else
            PresentMessage ERR_TMPINWORK $tmp_instdir $installdir
            PresentMessage INFO_INSTALLTERM
            mloop="0"
            get_out
         fi
      fi
   fi
done
status=$sysdir/Install_Log
#
if [[ ${product_name} = "IBM_WebSphere_Transformation_Extender" || \
      ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Application_Programming" || \
      ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Message_Broker" || \
      ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Integration_Servers" ]]; then

  allflag=0 
fi
#
saving_ifs=$IFS
SELECT_COMP
IFS=$saving_ifs

if [ "$info_prod" != "$oap" -a "$pver" = "5" ]; then
   print "PRODUCT\nDo_NOT_Remove_this_File\nIt_is_used_for_Service_Pack_Installations" >  $sysdir/.PRODUCT_$product_name
   print "$product_name $product_desc" >> $sysdir/.PRODUCT_$product_name
   if [ ! -z "$user" -a ! -z "$group" ]; then
   	chown -R "$user:$group" "$sysdir/.PRODUCT_$product_name" 2>>"$ERR"
   fi
   chmod 644 $sysdir/.PRODUCT_$product_name
   print "PRODVER\nDo_NOT_Remove_this_File\nIt_is_used_for_Service_Pack_Installations" >  $sysdir/.PRODVER_$product_name
   print "$pver $pverlong" >> $sysdir/.PRODVER_$product_name
   if [ ! -z "$user" -a ! -z "$group" ]; then
   	chown -R "$user:$group" "$sysdir/.PRODVER_$product_name" 2>>"$ERR"
   fi
   chmod 644 $sysdir/.PRODVER_$product_name
fi
if [ "$lib" = "yes" ]; then
   do_psubdir
   if [ $? -gt 0 ]; then
      PresentMessage ERR_DIRSPEC $prodfile
      PresentMessage ERR_SUPPORTINFO ${CompanyName}
      do_fail
   fi
   print "LIB\nDo_NOT_Remove_this_File\nIt_is_used_for_Service_Pack_Installations" >  $sysdir/.LIB_$product_name
   if [ ! -z "$user" -a ! -z "$group" ]; then
   	chown -R "$user:$group" "$sysdir/.LIB_$product_name" 2>>"$ERR"
   fi
   chmod 644 $sysdir/.LIB_$product_name
fi
status=$sysdir/Install_Log
if [ "$info_prod" != "$oap"  -a "$product_reinstall" = "no"  ]; then
   product_uninstall="$sysdir/$product_name.uninstall"
   print "#!/bin/ksh" > "$product_uninstall"
   print "# Uninstall script for $product_name" >> "$product_uninstall"
   chmod ug+x "$product_uninstall"
   if [ ! -z "$user" -a ! -z "$group" ]; then
      chown "$user:$group" "$product_uninstall" 2>>"$ERR"
   fi
fi
#################################################################################################
#	Added to solve TR 6007 to get actual disk space required on basis of components chosen
#	by user
#
space_of_tmpdir=0
typeset -i value_of_tar_space=0
typeset find_tar
while [ $num_comp -lt $compnum ]; do
  comp_tar_file=${prod[($arraysize*$num_comp)+6]}
  comp_select=${prod[($arraysize*$num_comp)+ix_select]}
  if [ "$comp_select" = "1" ]; then      
  	comp_tar_file="${comp_tar_file##*/}"
  	find_tar="$(cat  $locdir$infofile | grep $comp_tar_file)"
  	if [ ! -z "$find_tar" ];then
  		set $find_tar
  	else
  		PresentMessage ERR_TELLSPACENEED
		rm -rf $installdir 2>>"$ERR"
  		do_fail	
  	fi
  	if [ $# -lt 2 ];then
  		PresentMessage ERR_TELLSPACENEED
  		rm -rf $installdir 2>>"$ERR"	
  		do_fail
  	fi
  	value_of_tar_space=$2  	
  	(( install_space= $install_space + $value_of_tar_space ))
  fi
  num_comp=$num_comp+1
  value_of_tar_space=0
done

(( install_space= $install_space / 1024 ))
if [ "$ostype" = "HP-UX" -o ${ostype} = "ITANIUM"  ];then
  space_in_installdir="$(df -k $installdir | grep free)"
elif [ ${ostype} = "Linux" -o ${ostype} = "zLinux" ]; then
  space_in_installdir="$(df -k -P $installdir | tail -1 2>>"$ERR")"
else
  space_in_installdir="$(df -k $installdir | tail -1)"
fi

if [ ! -z "$space_in_installdir" ];then
        set $space_in_installdir
fi
if [ "$ostype" = "SunOS" ];then
        space_of_tmpdir=${4}
elif [ "$ostype" = "AIX" ];then
        space_of_tmpdir=${3}
elif [ "$ostype" = "Linux" -o ${ostype} = "zLinux" ];then
        space_of_tmpdir=${4}
elif [ "$ostype" = "OSF1" ];then
        space_of_tmpdir=${4}
elif [ "$ostype" = "HP-UX" -o ${ostype} = "ITANIUM" ];then
        space_of_tmpdir=${1}
fi

if [ "$space_of_tmpdir" -gt "$install_space" ];then
	:
else
	PresentMessage ERR_NOTENOUGHSPACE
	rm -rf $installdir 2>>"$ERR"	
	do_fail
fi
pn=0
while [ $pn -lt $compnum ]; do
  compindex=$(( ${arraysize} * ${pn} ))
  component=${prod[${compindex}+$ix_component]}  
  comptarfile=${prod[${compindex}+$ix_comptarfile]}
  compfile=${prod[${compindex}+$ix_compfile]}
  compvalid=${prod[${compindex}+$ix_nvalid]}
  compdesc=${prod[${compindex}+$ix_compdesc]}
  compname=${prod[${compindex}+$ix_compname]}
  compselect=${prod[${compindex}+ix_select]}
  
  if [ "$package_name" != "${prod[${compindex}+$ix_package_name]}" -o -z "$package_name" ]; then
    package_name=${prod[${compindex}+$ix_package_name]}
    package_desc=${prod[${compindex}+$ix_package_desc]}
#
#   the following insures that invisible components are always install. This is due to "packages"
#   being the overriding concern here, while the installer actually selects components. By appending
#   the package name associated with an invisible component, the containing package is explicitly included.
#
    if [[ ${prod[${compindex}+$ix_visible]} != "YES" ]]; then
      compselect=1
      package_select="${package_select} ${package_name}"
    fi
#
    if [ ! -z "$package_name" ]; then
      sel1=""
      for sel in $package_select; do
        if [ "$sel" = "$package_name" ]; then
          sel1=$sel
          break
        fi
      done
      if [ ! -z "$notsel" ]; then
        for nots in $notsel; do
          oldifs=$IFS
          IFS="_"
          set $nots
          IFS=$oldifs
          PresentMessage INFO_COMPINSTNOTSELECTED $@
        done
      fi
      PresentationDelay ${sleeptime_long}
      do_clear_screen
      notsel=""
      PresentMessage INFO_PREPINGINST $package_desc
      PresentationDelay ${sleeptime_long}
      if [ -z "$sel1" ]; then
        PresentMessage INFO_NOCOMPSELECTED $package_desc
        PresentationDelay ${sleeptime_long}
        continue
      fi
    fi
  fi
  if [ "$compvalid" = "invalid" ]; then
    install_error=$install_error+1
    pn=$pn+1
    PresentMessage ERR_INVALIDITEM $compdesc
    PresentMessage ERR_SUPPORTINFO ${CompanyName}
    do_fail
  fi
  if [ -f "$comptarfile" ]; then
    tmpnum=0
    for tmp in $comp_hide; do
      if [ "$tmp" = "$component" ]; then
        tmpnum=1
        break
      fi
    done
    #####Added to resolve TR 6849 on 04/02/01
    if [ "$component" = "shared" -a "$nothr_chosen" -eq 1 ];then
      shared_plat=1
    fi
    if [ "$compselect" = "1" ]; then
#
#     only check for duplicate visible components
#     
      inst_returncode=0
      if [[ ${prod[${compindex}+$ix_visible]} = "YES" ]]; then
        chk_dup_comp
        inst_returncode=$?
      fi
    fi
    if [[ ${prod[${compindex}+$ix_visible]} = "NO" || \
          ${inst_returncode} -eq 1 ]]; then
      if [ "$compselect" != "1" ]; then
        PresentMessage INFO_COMPINSTBYPASSED $compdesc
        PresentMessage INFO_COMPINSTNOTSELECTED $compdesc
        notsel="$notsel $compname"
        install_notselect=$install_notselect+1
        PresentationDelay ${sleeptime_long}
      else   
        inscomp $component $compfile $comptarfile
        tmp=$?  
        tell_about $tmp 
        list_of_uninstalls="$list_of_uninstalls $component.uninstall"            	
        PresentationDelay ${sleeptime_long}
      fi
      #wait_for_enter
    fi
  else
    PresentMessage ERR_NOCOMPTAR $compdesc
    PresentMessage INFO_BYPASSINGCOMP $compdesc
    PresentMessage ERR_SUPPORTINFO ${CompanyName}
    install_error=$install_error+1
    do_fail
  fi
  pn=$pn+1
done
#
if [ ! -f $installdir/libs/install.properties ];then
        print "InstallDir=$installdir"    > $installdir/libs/install.properties
        if [ -d "$installdir/docs" ];then
                print "HelpDir=$installdir/docs" >> $installdir/libs/install.properties
        else
                print "HelpDir=" >> $installdir/libs/install.properties
        fi
        print "Build=$info_ver"          >> $installdir/libs/install.properties
        if [ ! -z "$user" -a ! -z "$group" ]; then
                chown -R "$user:$group" "$installdir/libs/install.properties" 2>>"$ERR"
        fi
        print "$installdir/libs/install.properties $product_name" >> $sysdir/$common
        files_in_libs="$files_in_libs $installdir/libs/install.properties"
else
        copy_to_common install.properties $installdir/libs
fi

Remove_extension_file
#
###############################################################################################
#
#		TR 8500
#
if [ -f "$sysdir/platapi_nothr" -o  -f "$sysdir/platapi_nothrINT" ];then
 tmp="$(find $installdir $noleaf -type f -name "*_nothr*" -print | grep -v dtx_install 2>>$ERR)"
 for t in $tmp; do
  t1="${t%_nothr*}"
  t2="${t##*_nothr}"
  mv -f $t   $t1$t2        2>>$ERR
  Remove_Overwritten_Deleted_Files $t  
  if [ $? -gt 0 ]; then
     PresentMessage ERR_RENAMEERR $t $t1$t2
     do_fail
  fi
 done
#elif [ -f "$sysdir/platapi" -o  -f "$sysdir/platapiINT" ];then
else
 tmp="$(find $installdir $noleaf -type f -name "*_nothr*" -print 2>>$ERR)"
 for t in $tmp; do
  rm -f $t    2>>$ERR
  Remove_Overwritten_Deleted_Files $t  
 done  
fi 
               
if [ -d "$installdir/src" -a -d "$installdir/libs" ]; then
   ln -f $installdir/libs/* $installdir/src  2>>$ERR
fi

if [ "$info_prod" != "$oap" -a "$lib" = "yes" ]; then
   print "$allsubdir" >>  $sysdir/.LIB_$product_name
fi
#
# WTX00001421: attempt property file conversion.
#
propfile="$installdir/libs/install.properties"
convertclass="$installdir/libs/PropertiesConverter.class"
if [[ -f ${propfile} ]]; then
  if [[ -f ${convertclass} ]]; then
    $installdir/java/bin/java ${convertclass} -s ${propfile}
  fi
fi
#
# if existing configuration files have been retained, restore them now.
#
if [[ ${config_found} = 1 ]]; then
  RestoreConfiguration
fi
#
tmp="$(date 2>>"$ERR")"
PresentMessage INFO_TOTALCOMPS $compnum
if [ "$flag" -ne 1 ];then
  PresentMessage INFO_SELECTEDCOMPS $Total_Selected_Components
  PresentMessage INFO_SHAREDCOMPS $Total_Shared_Components
else
  PresentMessage INFO_SELECTEDCOMPS $(( compnum - Total_Shared_Components ))
  PresentMessage INFO_SHAREDCOMPS $Total_Shared_Components
fi
#
PresentMessage INFO_EXCLUDEDCOMPS $mutualExComp
PresentMessage INFO_COMPSINSTOK $install_good
PresentMessage INFO_COMPSINSTBAD $install_fail

if [ "$info_prod" != "$oap" ]; then
   print "$product_name installed: $tmp" >> $status
fi
if [ ! -z "$user" -a ! -z "$group" ];then
   chown "$user:$group" "$status" 2>>"$ERR"
fi
cat "$prodfile" > "$sysdir/$product_name"
if [ ! -z "$user" -a ! -z "$group" ];then
   chown "$user:$group" "$sysdir/$product_name" 2>>"$ERR"
fi
if [ "$product_reinstall" = "no" ];then 
	print "print \"Please wait...\" " >> "$product_uninstall"
	print "rm -f $sysdir/$product_name 2>>$NUL" >> "$product_uninstall"
fi
#tmp="$(find $sysdir $noleaf -name *.uninstall -print)"
tmp="$list_of_uninstalls"
if [ "$info_prod" != "$oap" -a  "$product_reinstall" = "no"  ]; then
   print "rm -f $sysdir/.LIB_$product_name 2>>$NUL" >> "$product_uninstall"
   print "rm -f $sysdir/.LINK 2>>$NUL" >> "$product_uninstall"
   print "rm -f $sysdir/.LAUNCHER 2>>$NUL" >> "$product_uninstall"
   print "rm -f $sysdir/.PRODVER_$product_name 2>>$NUL" >> "$product_uninstall"
   print "rm -f $sysdir/.PRODUCT_$product_name 2>>$NUL" >> "$product_uninstall"
   print "rm -f $sysdir/.MQSERIES 2>>$NUL" >> "$product_uninstall"
   for tmp1 in $tmp; do
      if [ "$tmp1" != "$product_uninstall" -a "$tmp1" != "$oproduct_uninstall" ]; then
       print "$sysdir/$tmp1 2>>$NUL" >> "$product_uninstall"
      fi
   done
   for tmp in $files_in_libs;do
   	tmp1="$(ls -i $tmp 2>> $ERR)"
   	tmp2="$tmp2 $tmp1"
   done 
   ################################################################
   #  TR 8575 "-type file" doesn't work on HP10
   #        changed to "-type f"
   for t in $tmp2; do
      tt="$(find $installdir/src $noleaf -type f -inum $t -print 2>>$ERR)"
      if [ ! -z "$tt" ]; then
         tdel="$tdel $tt"
      fi
   done
#
#  Do individual deletes as tdel is too long for rm command - 22jun2006
   for file_to_delete in $tdel
   do
      print "rm -f $file_to_delete 2>>$NUL" >> "$product_uninstall"
   done
#
# Re-engineered for WTX00025589
#
#   if [ "$product_reinstall" = "yes" ]; then
#   	print "rm -f $installdir/src/libadpora80.$sosl 2>>$NUL" >> "$product_uninstall"	
#   	print "rm -f $installdir/src/libdbora8.$sosl 2>>$NUL" >> "$product_uninstall"
#   fi
#   
#   if [ ! -z "$allsubdir" ];then
#   	for tmp2 in $allsubdir;do
#   		tmp3="$tmp2 $tmp3"
#   	done
#   	allsubdir="$tmp3"
#   fi
#
   if [ ! -z "$allsubdir" ]; then
     print "tmp=\"\$(ls -a $sysdir/.*PRODUCT* 2>> $NUL )\" "       >> "$product_uninstall"
     print "if [[ -z \${tmp} ]]; then  "	   >> "$product_uninstall"
     lastdir="" 
     for subd in $allsubdir; do
       if [[ ! -z ${lastdir} &&\
             "${lastdir}${subd#${lastdir}}" = "${subd}" ]]; then
         subd="${lastdir}"
       fi
#       
       if [[ -z ${lastdir} || ${subd} != ${lastdir} ]]; then    
         print "  rm -rf $subd 2>>$NUL"              >> "$product_uninstall"
         lastdir="${subd}"
       fi
     done
     print "  rm -f $sysdir/Install_Log 2>>$NUL"	>> "$product_uninstall" 
     print "fi"  				        >> "$product_uninstall"             
   fi
fi

#
# removed for WTX00025456
#
#if [ "$product_reinstall" = "no" ];then
#	print "if [ -d "$installdir/src" -a -d "$installdir/libs" ]; then"  >> "$product_uninstall"
#	print "   ln -f $installdir/libs/* $installdir/src  2>>$NUL \nfi"        >> "$product_uninstall"  
#fi
#	
tmp="$(date 2>>"$ERR")"
print "Installed: $tmp" >> "$sysdir/$product_name"

#popd
#Added 09/14/00 for more than 1 readme files
for readme_files in $readme_x; do
  if [ -f "$locdir$readme_files" ];then
    cp $locdir$readme_files $sysdir/$readme_files 2>> "$ERR" 
    if [ "$product_reinstall" = "no" ];then
      print "rm -f $sysdir/$readme_files 2>>$NUL" >> "$product_uninstall"
    fi
  fi
done

if [ -f "$sysdir/$common" ];then
	remove_from_list
fi

#create_awkfile
#
# ec 100417 - The prompt for netscape path should always occur in core installs
#             since the infocenter is always installed. This is being managed
#             with a flag as this may change in future.
#
typeset help_installed="TRUE"
if [[ ${inst_type} = "CORE" && ${help_installed} = "TRUE" ]];then
#
# assume a recorded install knows where netscape is
#
  if [[ ! -z ${bInteractive} && ${bInteractive} = "FALSE" ]]; then
# 
    PromptInstall ${TXBROWSER}
    path_of_netscape=${prompt_response}
    path_set=1    
  else
#
#   ask for broswer path
#
    path_set=0
    while [[ ${path_set} = 0 ]]; do
#
#     ask if path should be prompted for
#    
      PresentMessage PROMPT_NSINFO1
      yes_no 3 PROMPT_OKPATHMOD
      if [[ $? -eq 1 ]]; then     
        default_nsprompt=${prompt_resp[${TXBROWSER}]}
#
#       prompt until an acceptable path is provided
#
        while [[ ${path_set} = 0 ]]; do          
          prompt_resp[${TXBROWSER}]=${default_nsprompt}
          PresentMessage PROMPT_NSINFO2
          PromptInstall ${TXBROWSER}
          path_of_netscape=${prompt_response}
#
#         make sure the a path was entered
#      
          if [[ -f ${path_of_netscape} || -x ${path_of_netscape} ]]; then
	    path_of_netscape="${path_of_netscape%/*}"
          fi
#
#         if the browser path cannot be found, ask if it should be 
#         re-specified. Otherwise, it is used as is.
#	  
          if [[ ! -d ${path_of_netscape} ]]; then
	    yes_no 3 PROMPT_REENTERNSPATH
            if [[ $? = 1 ]]; then
              continue
            fi
          fi
          path_set=1
#
        done 
#
      else
#      
#       no path to be set.      
#
        break
      fi
    done
  fi
fi  
#  
#if [ -f "$sysdir/awkfile" ];then
#        rm -f $sysdir/awkfile 2>> $ERR
#fi
#
#TR 9107 - Include CLASSPATH for WI
if [ -f "$sysdir/javaapi1.4" ];then
 if [ -d "$installdir/WI/samples" ];then
 	set_classpath="$set_classpath $installdir/WI/samples"
 fi
 for jar_file in $installdir/WI/lib/WIMercServlet.jar $installdir/WI/lib/WIMercMapBean.jar $installdir/WI/lib/MercJXME.jar  $installdir/libs/mercjava.jar;do
 	if [ -f "$jar_file" ];then
 		set_classpath="$set_classpath $jar_file"
 	fi
 done	
fi
#
# if the ibm jre has been installed, signal that the 
# necessary java settings should be included in setup
#
if [[ ${inst_type} = "CORE" && -f "$sysdir/ibmjre" ]];then
  use_ibmjava=1
fi
#	
	
if [ "$info_prod" != "$oap" ]; then
  tmp="$(find $installdir $noleaf -name envsetup -print 2>>$ERR)"
   
  if [ ! -z "$tmp" ]; then
    for tmp11 in $tmp; do
    tmp12="$(echo $tmp11 | grep $tmp_instdir)"
    if [[ -z ${tmp12} ]]; then
      print "#!/bin/ksh" > $installdir/setup
      print "DTX_HOME_DIR=$installdir" >> $installdir/setup
#
#     if a jre has been installed, include it in the 
#     generated setup script
#
      if [[ -x $installdir/java/bin/java ]]; then 
        print "#" >> $installdir/setup
        print "JAVAHOME=\${DTX_HOME_DIR}/java" >> $installdir/setup
        print "export JAVAHOME" >> $installdir/setup
        print "#" >> $installdir/setup                          
#
        javapath_seg=""
#              
        case $ostype in
        "SunOS")
#
#         WTX00003531 - Incorrect shared library path setting
#         for Java in 64 bit installs
#
          if [[ ! -z ${Package_Wordsize} && ${Package_Wordsize} =  "64" ]]; then
            javapath_seg="sparcv9"
          else
            javapath_seg="sparc"
          fi
#                  
          print "if [[ -z \${${inst_libpathname}} ]]; then" >> $installdir/setup
          print "  ${inst_libpathname}=\${JAVAHOME}/lib/${javapath_seg}/server:\${JAVAHOME}/lib/${javapath_seg}" \
                                                  >> $installdir/setup
          print "else"                            >> $installdir/setup
          print "   if [ 0 -eq \`echo \$${inst_libpathname} | grep -c \"\${DTX_HOME_DIR}/java/lib/${javapath_seg}\"\` ]; then" \
                                                  >> $installdir/setup
          print "     ${inst_libpathname}=\${JAVAHOME}/lib/${javapath_seg}/server:\${JAVAHOME}/lib/${javapath_seg}:\${${inst_libpathname}} " \
                                                  >> $installdir/setup
          print "   fi"                           >> $installdir/setup
          print "fi"                              >> $installdir/setup
        ;;
        "AIX")
          print "if [[ -z \${${inst_libpathname}} ]]; then" >> $installdir/setup
          print "  ${inst_libpathname}=\${JAVAHOME}/bin:\${JAVAHOME}/bin/classic"\
                                                  >> $installdir/setup
          print "else"                            >> $installdir/setup
          print "  if [ 0 -eq \`echo \$${inst_libpathname} | grep -c \"\${DTX_HOME_DIR}/java/bin\"\` ]; then" \
                                                  >> $installdir/setup
          print "    ${inst_libpathname}=\${JAVAHOME}/bin:\${JAVAHOME}/bin/classic:\${${inst_libpathname}}" \
                                                  >> $installdir/setup
          print "  fi"                    >> $installdir/setup
          print "fi"                      >> $installdir/setup
        ;;
        "HP-UX")
#
#         WTX00003531 - Incorrect shared library path setting
#         for Java in 64 bit installs
#
          if [[ ! -z ${Package_Wordsize} && ${Package_Wordsize} =  "64" ]]; then
            javapath_seg="PA_RISC2.0W"
          else
            javapath_seg="PA_RISC2.0"
          fi
#                            
          print "if [[ -z \${${inst_libpathname}} ]]; then" >> $installdir/setup
          print "   ${inst_libpathname}=\${JAVAHOME}/lib/${javapath_seg}:\${JAVAHOME}/lib/${javapath_seg}/server" \
                                                >> $installdir/setup
          print "else"                    >> $installdir/setup
          print "  if [ 0 -eq \`echo \$${inst_libpathname} | grep -c \"\${DTX_HOME_DIR}/java/lib/${javapath_seg}\"\` ] ; then" \
                                                >> $installdir/setup
          print "    ${inst_libpathname}=\${JAVAHOME}/lib/${javapath_seg}:\${JAVAHOME}/lib/${javapath_seg}/server:\${${inst_libpathname}}" \
                                                >> $installdir/setup
          print "  fi"                    >> $installdir/setup
          print "fi"                      >> $installdir/setup
        ;;
        "ITANIUM")
#
#         WTX00003531 - Incorrect shared library path setting
#         for Java in 64 bit installs
#
          if [[ ! -z ${Package_Wordsize} && ${Package_Wordsize} =  "64" ]]; then
            javapath_seg="IA64W"
          else
            javapath_seg="IA64N"
          fi
#
          print "if [[ -z \${${inst_libpathname}} ]]; then" >> $installdir/setup
          print "  ${inst_libpathname}=\${JAVAHOME}/lib/${javapath_seg}:\${JAVAHOME}/lib/${javapath_seg}/server" \
                                                >> $installdir/setup
          print "else"                    >> $installdir/setup
          print "  if [ 0 -eq \`echo \$${inst_libpathname} | grep -c \"\${DTX_HOME_DIR}/java/lib/${javapath_seg}\"\` ]; then" \
                                                >> $installdir/setup
          print "    ${inst_libpathname}=\${JAVAHOME}/lib/${javapath_seg}:\${JAVAHOME}/lib/${javapath_seg}/server:\${${inst_libpathname}}" \
                                                >> $installdir/setup
          print "  fi"                    >> $installdir/setup
          print "fi"                      >> $installdir/setup
        ;;
#
        "Linux"|"zLinux")
          print "if [[ -z \${${inst_libpathname}} ]]; then" >> $installdir/setup
          print "  ${inst_libpathname}=\${JAVAHOME}/bin:\${JAVAHOME}/bin/classic" \
                                                >> $installdir/setup
          print "else"                    >> $installdir/setup
          print "  if [ 0 -eq \`echo \$${inst_libpathname} | grep -c \"\${DTX_HOME_DIR}/java/bin\"\` ]; then" \
                                                >> $installdir/setup
          print "    ${inst_libpathname}=\${JAVAHOME}/bin:\${JAVAHOME}/bin/classic:\${${inst_libpathname}}" \
                                                >> $installdir/setup
          print "  fi"                    >> $installdir/setup
          print "fi"                      >> $installdir/setup
        ;;
        esac
#
        print "export ${inst_libpathname}" >> $installdir/setup             
#
#
        if [[ ! -z ${javapath_seg} ]]; then
          if [[ ( ! -z ${Package_Wordsize} && ${Package_Wordsize} =  "64" ) ]]; then
            javapath_seg="/${javapath_seg}"
          else
            javapath_seg=""
          fi
        fi      
#           
        print "#" >> $installdir/setup
        print "if [[ -z \${PATH} ]]; then" >> $installdir/setup
        print "  PATH=\${JAVAHOME}/bin${javapath_seg}" >> $installdir/setup
        print "else" >> $installdir/setup
        print "  if [ 0 -eq \`echo \$PATH | grep -c \"\${JAVAHOME}/bin\"\` ]; then" >> $installdir/setup
        print "    PATH=\${JAVAHOME}/bin${javapath_seg}:\${PATH}" >> $installdir/setup
        print "  fi" >> $installdir/setup
        print "fi" >> $installdir/setup
        print "#" >> $installdir/setup        
#
        if [[ ( ! -z ${Package_Wordsize} && ${Package_Wordsize} =  "64" ) ]] &&\
		[[ "$ostype" = "SunOS" ]] || \
		[[ "$ostype" = "HP-UX" ]] || \
		[[ "$ostype" = "ITANIUM" ]]; then
          print "  DTX_JAVA_CMD=\${JAVAHOME}/bin${javapath_seg}/java" >> $installdir/setup
          print "  export DTX_JAVA_CMD" >> $installdir/setup
          print "#" >> $installdir/setup
        fi
        print "export PATH" >> $installdir/setup
        print "#" >> $installdir/setup
#
        if [ "$path_set" = 1 ];then
           print "PATH=\$PATH:$path_of_netscape" >> $installdir/setup
        fi
        print ". $tmp11 $installdir $set_classpath" >> $installdir/setup
        print "#" >> $installdir/setup
      fi
    fi
  done
#
#     Include odbc driver initialization.
#          
      print "#                                               " >> $installdir/setup
      print "if [[ -x \${DTX_HOME_DIR}/odbc_drivers/odbc.sh ]]; then" >> $installdir/setup
      print "  if [[ -z \${ODBC_DRIVERS_INITIALIZED} ]]; then" >> $installdir/setup
      print "    ODBC_DRIVERS_INITIALIZED=TRUE               " >> $installdir/setup
      print "    export ODBC_DRIVERS_INITIALIZED             " >> $installdir/setup
      print "    . \${DTX_HOME_DIR}/odbc_drivers/odbc.sh     " >> $installdir/setup
      print "  fi                                            " >> $installdir/setup
      print "fi                                              " >> $installdir/setup
      print "#                                               " >> $installdir/setup
#      
      chmod ug+x $installdir/setup
      if [ ! -z "$user" -a ! -z "$group" ]; then
         chown "$user:$group" "$installdir/setup" 2>>"$ERR"
      fi
      print "$installdir/setup $product_name" >> $sysdir/$common
   fi
fi
#
# Create any deferred links
#
if [[ ${#Def_links[*]} -gt 0 ]]; then
  compnum=0
  while [[ ${compnum} -lt ${#Def_links[*]} ]]; do
    oldifs=$IFS
    IFS=";"
    set ${Def_links[${compnum}]}
    IFS=$oldifs
    linkreplace_opt=${1}
    link_ovrw=${2}
    link_share=${3}
    linktarget=${4}
    linkname=${5}
    perm=${6}    
    component_uninstall=${7}
    new_dolink ${linkreplace_opt} ${link_ovrw} ${link_share} ${linktarget} ${linkname} ${perm} ${component_uninstall}
    rc=$?
    if [[ ${rc} = 0 ]]; then
      PresentMessage INFO_LINKOK ${linkname} ${linktarget}           
    else
      PresentMessage ERR_SYMLINKFAIL ${linkname} ${linktarget}
    fi
    compnum=$(( ${compnum} + 1 ))
  done
fi
# 
if [ -f "$readme" ]; then
  cp $readme $sysdir/$product_name.readme 2>> "$ERR"
  if [[ ! -z ${user} && ! -z ${group} ]]; then
    chown "$user:$group" "$sysdir/$product_name.readme" 2>>"$ERR"
  fi
  readmefile=$sysdir/$product_name.readme
  if [ "$product_reinstall" = "no" ];then
    print "rm -f $readmefile 2>>$NUL" >> "$product_uninstall"
  fi	
fi
#
if [[ -f ${license_file} ]]; then
  if [[ -f ${installdir}/LICENSE.TXT ]]; then rm ${installdir}/LICENSE.TXT; fi
  new_dolink ALWAYS 1 1 ${installdir}/license/LA_${locale_name}.txt ${installdir}/LICENSE.TXT "755"
fi
#
#
if [[ ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Message_Broker" || \
      ${product_name} = "IBM_WebSphere_Transformation_Extender_for_Integration_Servers" ]]; then

  if [[ ${WMB_Found} = "TRUE" ]]; then
#
#   Complete setup activities for WebSphere Message Broker integration.
#   create a v6 message broker setup profile script to be copied to the 
#   profile area for the broker to run when started.
#
    mqsi_profile_name="${MQSI_FILEROOT}"
    if [[ ! -z ${Package_Wordsize} ]]; then
      mqsi_profile_name="${mqsi_profile_name}_${Package_Wordsize}"
    fi
    mqsi_profile_name="${mqsi_profile_name}.sh"
    mqsi_profile="${installdir}/wmqi/${mqsi_profile_name}"
#
#   per The mqsi profile script must establish the environment using word length
#   specific MQSI variables. The WTX environment setup is mirrored here. 
#   This installation is targeted towards a 32 installer. Should 64 bit support
#   be implemented, this section will require additional updates.
#
    print "#!/bin/ksh                                   " > ${mqsi_profile}
    print "# (c) Copyright IBM Corp. 2008               " >> ${mqsi_profile}
    print "#                                            " >> ${mqsi_profile}
    print "# DTX setup script                           " >> ${mqsi_profile}
    print "#                                            " >> ${mqsi_profile}
#
#   Provide word length qualified home directory specification
#
    if [[ ! -z ${Package_Wordsize} ]]; then
      print "DTX_HOME_DIR_${Package_Wordsize}=${installdir} " >> ${mqsi_profile} 
      print "export DTX_HOME_DIR_${Package_Wordsize}      " >> ${mqsi_profile} 
      print "DTX_DIR=\${DTX_HOME_DIR_${Package_Wordsize}} " >> ${mqsi_profile}
    else
      print "DTX_DIR=${installdir}                   " >> ${mqsi_profile}      
    fi
#        
#   print "export DTX_HOME_DIR                          " >> ${mqsi_profile}
#
    print "#                                            " >> ${mqsi_profile}
    print "DTX_LIBS=\${DTX_DIR}/libs                    " >> ${mqsi_profile}
    print "DTX_LIL=\${DTX_DIR}/wmqi                     " >> ${mqsi_profile}  
    print "#                                            " >> ${mqsi_profile}
#
#   At invocation the mqsi profile determines the version of the
#   invoking broker. A 6.1 broker is minimum requirement for 8.2.0.1.
#
    print "MQSI61=\"false\"                           " >> ${mqsi_profile}  
    print "if [[ ! -z \${MQSI_VERSION} ]]; then         " >> ${mqsi_profile}  
    print "  if [[ ! -z \${MQSI_VERSION_V} && \\" >> ${mqsi_profile} 
    print "         \${MQSI_VERSION_V} -gt 6 ]]; then" >> ${mqsi_profile}  
    print "    MQSI61=\"true\"                      " >> ${mqsi_profile}  
    print "  else                                       " >> ${mqsi_profile}
    print "    if [[ ( ( ! -z \${MQSI_VERSION_V} && \\" >> ${mqsi_profile} 
    print "           \${MQSI_VERSION_V} -ge 6 ) && \\" >> ${mqsi_profile}  
    print "        ( ! -z \${MQSI_VERSION_R} && \\" >> ${mqsi_profile}  
    print "           \${MQSI_VERSION_R} -ge 1 )) ]]; then  " >> ${mqsi_profile}  
    print "      MQSI61=\"true\"                      " >> ${mqsi_profile}
    print "    fi                                       " >> ${mqsi_profile}      
    print "  fi                                         " >> ${mqsi_profile}  
    print "fi                                           " >> ${mqsi_profile}   
    print "#                                            " >> ${mqsi_profile}
    print "if [[ \${MQSI61} = \"true\" ]]; then         " >> ${mqsi_profile}  
    print "#                                            " >> ${mqsi_profile}  
#
#   profile content varies by tx library word size. 64 bit is used if specified
#
    if [[ ! -z ${Package_Wordsize} && ${Package_Wordsize} =  "64" ]]; then
      print "# 64 bit profile                             " >> ${mqsi_profile}
      print "#                                            " >> ${mqsi_profile}
#
#     WTX00026985 - TX WMB integration profile must only allow
#                   support for 64 bit MB on Itanium and zLinux.
#                   No word length qualified integration variables should
#                   be used.
#     WTX00026989 - TX WMB integration profile must use word length
#                   qualified LILPATH for 64 bit only MB on Itanium
#                   and zLinux
#
      if [[ ${ostype} = "zLinux" || ${ostype} = "ITANIUM" ]]; then
#
        print "  if [[ -z \${${inst_libpathname}} ]]; then  " >> ${mqsi_profile}
        print "    ${inst_libpathname}=\${DTX_LIBS}         " >> ${mqsi_profile}
        print "  else                                       " >> ${mqsi_profile}
        print "    if [ 0 -eq \`echo \${${inst_libpathname}} | \\" >> ${mqsi_profile}
        print "        grep -c \"\${DTX_LIBS}\"\` ]; then   " >> ${mqsi_profile}
        print "      ${inst_libpathname}=\${${inst_libpathname}}:\${DTX_LIBS} " >> ${mqsi_profile}
        print "    fi                                       " >> ${mqsi_profile}
        print "  fi                                         " >> ${mqsi_profile}
        print "  export ${inst_libpathname}                 " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}
        print "  if [[ -z \${MQSI_LILPATH64} ]]; then       " >> ${mqsi_profile}
        print "    MQSI_LILPATH64=\${DTX_LIL}               " >> ${mqsi_profile}
        print "  else                                       " >> ${mqsi_profile}
        print "    if [ 0 -eq \`echo \${MQSI_LILPATH64} | \\" >> ${mqsi_profile}
        print "         grep -c \"\${DTX_LIL}\"\` ]; then   " >> ${mqsi_profile}
        print "      MQSI_LILPATH64=\${MQSI_LILPATH64}:\${DTX_LIL} " >> ${mqsi_profile}
        print "    fi                                       " >> ${mqsi_profile}
        print "  fi                                         " >> ${mqsi_profile}
        print "  export MQSI_LILPATH64                      " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}
#        
      else
#      
        print "# Note: MQSI_LIBPATH32 must exist for        " >> ${mqsi_profile}      
        print "#       64 bit TX                            " >> ${mqsi_profile}      
        print "#                                            " >> ${mqsi_profile}
        print "  if [[ ! -z \${MQSI_LIBPATH32} ]]; then     " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}     
        print "    if [[ -z \${MQSI_LILPATH64} ]]; then     " >> ${mqsi_profile}
        print "      MQSI_LILPATH64=\${DTX_LIL}             " >> ${mqsi_profile}
        print "    else                                     " >> ${mqsi_profile}
        print "      if [ 0 -eq \`echo \${MQSI_LILPATH64} | \\" >> ${mqsi_profile}
        print "           grep -c \"\${DTX_LIL}\"\` ]; then " >> ${mqsi_profile}
        print "        MQSI_LILPATH64=\${MQSI_LILPATH64}:\${DTX_LIL} " >> ${mqsi_profile}
        print "      fi                                     " >> ${mqsi_profile}
        print "    fi                                       " >> ${mqsi_profile}
        print "    export MQSI_LILPATH64                    " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}
        print "    if [[ -z \${${inst_libpathname}} ]]; then " >> ${mqsi_profile}
        print "      ${inst_libpathname}=\${DTX_LIBS}       " >> ${mqsi_profile}
        print "    else                                     " >> ${mqsi_profile}
        print "      if [ 0 -eq \`echo \${${inst_libpathname}} | \\" >> ${mqsi_profile}
        print "         grep -c \"\${DTX_LIBS}\"\` ]; then  " >> ${mqsi_profile}
        print "        ${inst_libpathname}=\${${inst_libpathname}}:\${DTX_LIBS} " >> ${mqsi_profile}
        print "      fi                                     " >> ${mqsi_profile}
        print "    fi                                       " >> ${mqsi_profile}
        print "    export ${inst_libpathname}               " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}     
#    
#       record unsupported word length combination
#    
        print "  else                                       " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}
        print "#   log word length combination              " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}      
        print "    print \"Unsupported MB word length for 64 bit TX\" \\" >> ${mqsi_profile}
        print "          >> \${DTX_LIL}/wtx_init.err        " >> ${mqsi_profile}
        print "    exit 1                                   " >> ${mqsi_profile}
        print "  fi                                         " >> ${mqsi_profile}
        print "#                                            " >> ${mqsi_profile}
      fi
    else
#
#   32 bit profile is the default.
#    
      print "# 32 bit profile                             " >> ${mqsi_profile}
      print "#                                            " >> ${mqsi_profile}            
      print "  if [[ -z \${MQSI_LILPATH32} ]]; then       " >> ${mqsi_profile}
      print "    MQSI_LILPATH32=\${DTX_LIL}               " >> ${mqsi_profile}
      print "  else                                       " >> ${mqsi_profile}
      print "    if [ 0 -eq \`echo \${MQSI_LILPATH32} | \\" >> ${mqsi_profile}
      print "         grep -c \"\${DTX_LIL}\"\` ]; then   " >> ${mqsi_profile}
      print "      MQSI_LILPATH32=\${MQSI_LILPATH32}:\${DTX_LIL} " >> ${mqsi_profile}
      print "    fi                                       " >> ${mqsi_profile}
      print "  fi                                         " >> ${mqsi_profile}
      print "  export MQSI_LILPATH32                      " >> ${mqsi_profile}
      print "#                                            " >> ${mqsi_profile}
      print "  if [[ -z \${MQSI_LIBPATH32} ]]; then       " >> ${mqsi_profile}
      print "    if [[ -z \${${inst_libpathname}} ]]; then " >> ${mqsi_profile}
      print "      ${inst_libpathname}=\${DTX_LIBS}        " >> ${mqsi_profile}
      print "    else                                     " >> ${mqsi_profile}
      print "      if [ 0 -eq \`echo \${${inst_libpathname}} | \\" >> ${mqsi_profile}
      print "         grep -c \"\${DTX_LIBS}\"\` ]; then  " >> ${mqsi_profile}
      print "         ${inst_libpathname}=\${${inst_libpathname}}:\${DTX_LIBS} " >> ${mqsi_profile}
      print "      fi                                     " >> ${mqsi_profile}
      print "    fi                                       " >> ${mqsi_profile}
      print "    export ${inst_libpathname}               " >> ${mqsi_profile}
      print "#                                            " >> ${mqsi_profile}
      print "  else                                       " >> ${mqsi_profile}
      print "    if [ 0 -eq \`echo \${MQSI_LIBPATH32} | \\" >> ${mqsi_profile}
      print "         grep -c \"\${DTX_LIBS}\"\` ]; then  " >> ${mqsi_profile}
      print "      MQSI_LIBPATH32=\${MQSI_LIBPATH32}:\${DTX_LIBS} " >> ${mqsi_profile}
      print "    fi                                       " >> ${mqsi_profile}  
      print "  fi                                         " >> ${mqsi_profile}
      print "  export MQSI_LIBPATH32                      " >> ${mqsi_profile}
      print "#                                            " >> ${mqsi_profile}
    fi
#
#     WTX00024593 - Message Broker java integration elements must be
#                   included in the classpath
#
    print "  if [[ -z \${CLASSPATH} ]]; then              " >> ${mqsi_profile}
    print "    CLASSPATH=\${DTX_LIL}/${MQSI_FILEROOT}.jar " >> ${mqsi_profile}
    print "    CLASSPATH=\${CLASSPATH}:\${DTX_LIBS}/dtxpi.jar" >> ${mqsi_profile}      
    print "  else                                         " >> ${mqsi_profile}
    print "    if [ 0 -eq \`echo \${CLASSPATH} | \\" >> ${mqsi_profile}
    print "       grep -c \"${MQSI_FILEROOT}.jar\"\` ]; then " >> ${mqsi_profile}
    print "      CLASSPATH=\${CLASSPATH}:\${DTX_LIL}/${MQSI_FILEROOT}.jar " >> ${mqsi_profile}
    print "      CLASSPATH=\${CLASSPATH}:\${DTX_LIBS}/dtxpi.jar             " >> ${mqsi_profile}      
    print "    fi                                         " >> ${mqsi_profile}
    print "  fi                                           " >> ${mqsi_profile}
    print "  export CLASSPATH                             " >> ${mqsi_profile}
    print "#                                              " >> ${mqsi_profile}    
    print "  if [[ -z \${NLSPATH} ]]; then              " >> ${mqsi_profile}
    print "    NLSPATH=\${DTX_LIL}/messages/%L/%N       " >> ${mqsi_profile}
    print "    NLSPATH=\${NLSPATH}:\${DTX_LIL}/messages/En_US/%N " >> ${mqsi_profile}
    print "  else                                       " >> ${mqsi_profile}
    print "    if [ 0 -eq \`echo \${NLSPATH} | \\" >> ${mqsi_profile}
    print "         grep -c \"\${DTX_LIL}\"\` ]; then   " >> ${mqsi_profile}
    print "      NLSPATH=\${NLSPATH}:\${DTX_LIL}/messages/%L/%N" >> ${mqsi_profile}
    print "      NLSPATH=\${NLSPATH}:\${DTX_LIL}/messages/En_US/%N" >> ${mqsi_profile}    
    print "    fi                                       " >> ${mqsi_profile}
    print "  fi                                         " >> ${mqsi_profile}
    print "  export NLSPATH                             " >> ${mqsi_profile}
    print "#                                            " >> ${mqsi_profile}
#    
#   record unsupported MB version invocation
#    
    print "else                                         " >> ${mqsi_profile}
    print "# log unsupported broker version               " >> ${mqsi_profile}
    print "  print \"Unsupported broker version \${MQSI_VERSION:-NONE}\" \\" >> ${mqsi_profile}
    print "    >> \${DTX_LIL}/wtx_init.err              " >> ${mqsi_profile}
    print "fi                                           " >> ${mqsi_profile}
    print "#                                            " >> ${mqsi_profile}
#
    chmod  "a+x" ${mqsi_profile}
    if [[ ! -z ${user} && ! -z ${group} ]]; then
      chown  "$user:$group" ${msqi_profile} 2>>"$ERR"
    fi     
    if [[ ${product_reinstall} = "no" ]];then
      print "rm -f ${msqi_profile} 2>>$NUL" >> "$product_uninstall"
      print "rm -rf ${installdir}/wmqi 2>>$NUL" >> "$product_uninstall"
    fi
#
#   Deploy the created third party profile 
#   if a profile already exists, insure it can be replaced.
#
    set_lil=FALSE
    if [[ -f ${WBI_V6x_PROPATH}/${mqsi_profile_name} ]]; then    
      yes_no 1 PROMPT_PLUGINFILEREP profile
      rc=$?
      if [[ ${rc} != 0 ]]; then
        set_lil=TRUE
      else
        PresentMessage INFO_KEPTPLUGIN
      fi    
    else
      set_lil=TRUE
    fi    
#
#   if indicated, copy to created profile for use by the v6 Message Broker
#
    if [[ ${set_lil} = "TRUE" ]]; then
      cp -p ${mqsi_profile} ${WBI_V6x_PROPATH}/${mqsi_profile_name} 2>>${ERR}
      rc=$?
      if [[ ${rc} != 0 ]]; then
        PresentMessage ERR_PLUGINCONFIGCOPYERR ${rc}
        if [[ ! -z ${IAMROOT} && ${IAMROOT} != TRUE ]]; then
          PresentMessage INFO_INSTALLASROOT
        fi         
        PresentMessage INFO_INSTTERM
        PresentMessage ERR_SUPPORTINFO ${CompanyName}
        do_fail
      else
#
#       record deployed profile for uninstall
#
        if [[ ${product_reinstall} = "no" ]]; then
          print "rm -f ${WBI_V6x_PROPATH}/${mqsi_profile_name} 2>>$NUL" >> ${product_uninstall}
        fi     
      fi
    fi  
  fi
# 
#
#  For Integration server, try and copy the OSGi bundle to the located process 
#  server installations. 
#
  typeset -i pathindx=0
#
  if [[ ${WPS_Found} = "TRUE" && ${#WPS_Installs[*]} -gt 0 ]]; then
    pathindx=0
#
#   copy the bundle to each located WPS installation
#  
    while [[ ${pathindx} -lt ${#WPS_Installs[*]} ]]; do
      WPSPath=${WPS_Installs[${pathindx}]}
      if [[ ! -d ${WPSPath} ]]; then
        PresentMessage INFO_CREATEPLUGINDIRWPS ${WPSPath}
        mkdir -p ${WPSPath} 1 >> ${ERR} 2>&1
        rc=$?
        if [[ ${rc} != 0 ]]; then
          PresentMessage ERR_CREATEWPSPLUGINDIR ${WPSPath} ${rc}
          pathindx=$(( ${pathindx} + 1 ))
          continue
        else
          chmod 777 ${WPSPath} 2>> ${ERR}
        fi
      fi
#
#     copy plugin to created directory
#   
      bundlepath="${installdir}/OSGibundles"
      bundle="${bundlepath}/${BundleName}"
#    
      if [[ -f ${bundle} ]]; then 
        PresentMessage INFO_COPYWPSPLUGIN ${BundleName} ${WPSPath}
        cp -p ${bundle} ${WPSPath}/${BundleName} 1>> ${ERR} 2>&1
        rc=$?
        if [[ ${rc} != 0 ]]; then
          PresentMessage ERR_COPYPLUGINTOWPS ${BundleName} ${WPSPath} ${rc}
        else
#
#         insure plugin is executable and record for removal
#
          if [[ -f ${WPSPath}/${BundleName} ]]; then
            PresentMessage INFO_WPSPLUGINOK ${BundleName} ${WPSPath}
            chmod 775 ${WPSPath}/${BundleName} 2>> ${ERR}
            print "rm -f ${WPSPath}/${BundleName} 2>>$NUL" >> ${product_uninstall}
          else
            PresentMessage ERR_COPYPLUGINTOWPS ${BundleName} ${WPSPath} 99
          fi
        fi
      else
        PresentMessage ERR_CRITICALFILEMISSING "OSGibundles/${BundleName}"
        PresentMessage ERR_SUPPORTINFO ${CompanyName}
        do_fail    
      fi 
      pathindx=$(( ${pathindx} + 1 ))
    done
  fi
fi
#
print "rm -f $product_uninstall 2>>$NUL"            >> "$product_uninstall"
print "if [ 3 = \`ls -a1 $sysdir | wc -l\` ]; then" >> "$product_uninstall"
print "\trm -f $sysdir/.List 2>>$NUL"               >> "$product_uninstall"
print "fi"                                          >> "$product_uninstall"
print "rm -rf ${sysdir} 2>>$NUL"                    >> "$product_uninstall"
print "rm -rf ${installdir} 2>>$NUL"                >> "$product_uninstall"
#
PresentMessage INFO_INSTCOMPLETE $product_desc 
#
# create recorded installation file if requested.
#
if [[ ! -z ${bRecording} && ${bRecording} = "TRUE" ]]; then
  if [[ ! -z ${recordfile} ]]; then
#
#   if only a file name is given, write the record file to the
#   newly created installation directory
#
    if [[ ${recordfile} = ${recordfile##*/} ]]; then
      recordfile="${installdir}/${recordfile}"
    fi
    touch ${recordfile}
    inst_returncode=$?
    if [[ ${inst_returncode} = 0 ]]; then
      PresentMessage INFO_RECORDING ${recordfile}
      print "# " > ${recordfile}
      print "# Recorded installation file for ${info_desc} version ${info_ver}" >> ${recordfile}
      timestamp=$(date +'%m.%d.%Y-%H:%M')
      print "# Recorded installation performed on ${timestamp}" >> ${recordfile}
      print "# " >> ${recordfile}
      array_index=0
      while [[ ${array_index} -le ${TXMAXPROMPT} ]]; do
        print "# " >> ${recordfile}
        print "# ${prompt_desc[${array_index}]} " >> ${recordfile}
        print "${prompt_tag[${array_index}]}:${prompt_resp[${array_index}]}" >> ${recordfile}
        print "# " >> ${recordfile}
        array_index=$(( ${array_index} + 1 ))
      done
      print "# " >> ${recordfile} 
    else
      PresentMessage ERR_RECORDFAILED ${recordfile}
    fi
  else
    PresentMessage ERR_NORECFILENAME
  fi
fi
#
if [ -s "$readmefile" -a ${bInteractive} = "TRUE" ]; then
  yes_no 1 PROMPT_READRELEASENOTES $product_desc
  if [ $? -eq 1 ]; then
    PresentMessage INFO_VIINFO
    PresentMessage INFO_READYTOVI
    read
    vi -R $readmefile
  fi
fi	
#
if [ -f "$readmefile" -a ! -s "$readmefile" ]; then
   rm $readmefile 2 >> $NUL
fi
#
clr_tmpdir
#
return ${inst_returncode}
#
