commEnv.sh

 


### commEnv.sh
### 
### This script is used to set up a common environment for starting WebLogic
### Server, as well as WebLogic development.  
###
### It sets the following variables:
###
###     BEA_HOME            - The home directory of all your BEA installation.
###     WL_HOME             - The root directory of the BEA installation.
###     JAVA_HOME           - Location of the version of Java used to start WebLogic 
###                           Server. See the WebLogic platform support page
###                           for an up-to-date list of supported JVMs on your platform.
###     JAVA_VENDOR         - Vendor of the JVM (i.e. BEA, HP, IBM, Sun, etc.)
###     PATH                - JDK and WebLogic directories will be added to the system path.  
###     WEBLOGIC_CLASSPATH  - Classpath required to start WebLogic Server.
###     LD_LIBRARY_PATH, LIBPATH and SHLIB_PATH    
###                         - Locate native libraries.
###     JAVA_VM             - The java arg specifying the VM to run.  (e.g. -server, -hotspot, etc.)
###     MEM_ARGS            - The variable to override the standard memory arguments passed to java.
###     CLASSPATHSEP        - CLASSPATH delimiter.
###     PATHSEP             - Path delimiter.
###     POINTBASE_HOME      - Point Base home directory.
###     POINTBASE_TOOL      - PointBase tools jar.
###     POINTBASE_CLASSPATH - Classpath needed to start PointBase. 
###     PRODUCTION_MODE     - Indicates if the Server will be started in PRODUCTION_MODE
###
### It exports the following function:
###
###     trapSIGINT     - Get actual PointBase PID when running in MKSNT environment;
###                      trap SIGINT to make sure PointBase will also be stopped.
### 
###     resetFd        - Reset the number of open file descriptors to 1024.
###
### jDriver for Oracle users: 
###    This script assumes that native libraries required
###    for jDriver for Oracle have been installed in the proper location and that 
###    your os specific library path variable (i.e. LD_LIBRARY_PATH/solaris, 
###    SHLIB_PATH/hpux, etc...) has been set appropriately.  Also note that this 
###    script defaults to the oci817_8 version of the shared libraries. If this is 
###    not the version you need, please adjust the library path variable 
###    accordingly.  
###
### For additional information, refer to the HOME
  JAVA_HOME="/opt/bea/jdk141_02"
  ### Set up JAVA VENDOR, possible values are
  ###BEA, HP, IBM, Sun ...
  JAVA_VENDOR=Sun
  ### PRODUCTION_MODE, default to the development mode
  PRODUCTION_MODE=""
fi 

export BEA_HOME WL_HOME JAVA_HOME JAVA_VENDOR PRODUCTION_MODE


### Set up JVM options base on value of JAVA_VENDOR
if [ "$PRODUCTION_MODE" = "true" ]
then
  case $JAVA_VENDOR in
  BEA)
    JAVA_VM=-jrockit
    MEM_ARGS="-Xms128m -Xmx256m"
  ;;
  HP)
    JAVA_VM=-server
    MEM_ARGS="-Xms32m -Xmx200m"
  ;;
  IBM)
    JAVA_VM=
    MEM_ARGS="-Xms32m -Xmx200m"
  ;;
  Sun)
    JAVA_VM=-server
    MEM_ARGS="-Xms32m -Xmx200m -XX:MaxPermSize=128m"
  ;;
  *)
    JAVA_VM=
    MEM_ARGS="-Xms32m -Xmx200m"
  ;;
  esac
else
  case $JAVA_VENDOR in
  BEA)
    JAVA_VM=-jrockit
    MEM_ARGS="-Xms128m -Xmx256m"
  ;;
  HP)
    JAVA_VM=-client
    MEM_ARGS="-Xms32m -Xmx200m"
  ;;
  IBM)
    JAVA_VM=
    MEM_ARGS="-Xms32m -Xmx200m"
  ;;
  Sun)
    JAVA_VM=-client
    MEM_ARGS="-Xms32m -Xmx200m -XX:MaxPermSize=128m"
  ;;
  *)
    JAVA_VM=
    MEM_ARGS="-Xms32m -Xmx200m"
  ;;
  esac
fi
export JAVA_VM MEM_ARGS


### Figure out how to load java native libraries
case `uname -s` in
AIX)
  if [ -n "${LIBPATH}" ]
  then
    LIBPATH=${LIBPATH}:${WL_HOME}/server/lib/aix
  else
    LIBPATH=${WL_HOME}/server/lib/aix
  fi
  export LIBPATH 
;;
HP-UX)
  if [ -n "${SHLIB_PATH}" ]
  then
    SHLIB_PATH=${SHLIB_PATH}:${WL_HOME}/server/lib/hpux11:${WL_HOME}/server/lib/hpux11/oci817_8
  else
    SHLIB_PATH=${WL_HOME}/server/lib/hpux11:${WL_HOME}/server/lib/hpux11/oci817_8
  fi
  export SHLIB_PATH
;;
LINUX|Linux)
 arch=`uname -m`
  if [ -n "${LD_LIBRARY_PATH}" ]
  then
    LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${WL_HOME}/server/lib/linux/${arch}:${WL_HOME}/server/lib/linux/${arch}/oci817_8
  else
    LD_LIBRARY_PATH=${WL_HOME}/server/lib/linux/${arch}:${WL_HOME}/server/lib/linux/${arch}/oci817_8
  fi
  export LD_LIBRARY_PATH
;;
OSF1)
  if [ -n "${LD_LIBRARY_PATH}" ]
  then
    LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${WL_HOME}/server/lib/tru64unix
  else
    LD_LIBRARY_PATH=${WL_HOME}/server/lib/tru64unix
  fi
  export LD_LIBRARY_PATH
;;
SunOS)
  if [ -n "${LD_LIBRARY_PATH}" ]
  then
    LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${WL_HOME}/server/lib/solaris:${WL_HOME}/server/lib/solaris/oci817_8
  else
    LD_LIBRARY_PATH=${WL_HOME}/server/lib/solaris:${WL_HOME}/server/lib/solaris/oci817_8
  fi
  export LD_LIBRARY_PATH
;;
Windows_NT*)
  CLASSPATHSEP=\;
  PATHSEP=\;
;;
CYGWIN*)
  CLASSPATHSEP=\;
;;
*)
  echo "$0: Don't know how to set the shared library path for `uname -s`.  "
esac


if [ "${CLASSPATHSEP}" = "" ]
then
  CLASSPATHSEP=:
fi
if [ "${PATHSEP}" = "" ]
then
  PATHSEP=:
fi
export PATHSEP CLASSPATHSEP

WEBLOGIC_CLASSPATH="${JAVA_HOME}/lib/tools.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.jar${CLASSPATHSEP}${WL_HOME}/server/lib/ojdbc14.jar"
export WEBLOGIC_CLASSPATH 

### PointBase configuration
POINTBASE_HOME="${WL_HOME}/common/eval/pointbase"
POINTBASE_CLASSPATH="${CLASSPATHSEP}${POINTBASE_HOME}/lib/pbserver44.jar${CLASSPATHSEP}${POINTBASE_HOME}/lib/pbclient44.jar"
POINTBASE_TOOLS="${POINTBASE_HOME}/lib/pbtools44.jar"
export POINTBASE_HOME POINTBASE_CLASSPATH POINTBASE_TOOLS

###
### Set up PATH
###
if [ `uname -s` = "CYGWIN32/NT" ]
then

  ###
  ### If we are on an old version of Cygnus we need to turn 
  ### <letter>:/ in the path to //<letter>/
  ###

  WL_HOME_CYGWIN=`echo $WL_HOME | sed 's###\([a-zA-Z]\):###//\1###g'`
  JAVA_HOME_CYGWIN=`echo $JAVA_HOME | sed 's###\([a-zA-Z]\):###//\1###g'`
  PATH="${WL_HOME_CYGWIN}/server/bin${PATHSEP}${JAVA_HOME_CYGWIN}/jre/bin${PATHSEP}${JAVA_HOME_CYGWIN}/bin${PATHSEP}${PATH}"
else

  if [ -n "`uname -s |grep -i cygwin_`" ]
  then

    ###
    ### If we are on an new version of Cygnus we need to turn 
    ### <letter>:/ in the path to /cygdrive/<letter>/

    CYGDRIVE=`mount -ps | tail -1 | awk '{print $1}' | sed -e 's%/$%%'`
    WL_HOME_CYGWIN=`echo $WL_HOME | sed "s###\([a-zA-Z]\):###${CYGDRIVE}/\1###g"`
    JAVA_HOME_CYGWIN=`echo $JAVA_HOME | sed "s###\([a-zA-Z]\):###${CYGDRIVE}/\1###g"`
    PATH="${WL_HOME_CYGWIN}/server/bin${PATHSEP}${JAVA_HOME_CYGWIN}/jre/bin${PATHSEP}${JAVA_HOME_CYGWIN}/bin${PATHSEP}${PATH}"
  else
    ### set PATH for other shell environments
    PATH="${WL_HOME}/server/bin${PATHSEP}${JAVA_HOME}/jre/bin${PATHSEP}${JAVA_HOME}/bin${PATHSEP}${PATH}"
  fi
fi



###
### limit the number of open file descriptors
###

resetFd() {
  if [ ! -n "`uname -s |grep -i cygwin || uname -s |grep -i windows_nt`" ]
  then
    maxfiles=`ulimit -H -n`
    if [ ! $? -a "${maxfiles}" != 1024 ]
    then
      if [ "${maxfiles}" = "unlimited" ]
      then
        maxfiles=1025
      fi
      if [ "${maxfiles}" -lt 1024 ]
      then
        ulimit -n ${maxfiles}
      else
        ulimit -n 1024
      fi
    fi
  fi
}




###
### Get actual PointBase process when running in MKS/NT environment;
###
### Trap SIGINT
###
###  input:
###    POINTBASE_PID -- PointBase server process id.
###  output:
###    POINTBASE_PID -- Actual PointBase pid in MKS/NT environment.
###

trapSIGINT() {

  ### With MKS, the pid of $! dosen't show up correctly.
  ### It starts a shell process to launch whatever commands it calls.
  if [ `uname -s` = "Windows_NT" ]
  then
    POINTBASE_PID=`ps -eo pid,ppid | 
      awk -v POINTBASE_PID=${POINTBASE_PID} '$2 == POINTBASE_PID {print $1}'`
  fi

  ### Kill pointbase on interrupt from this script (^C)
  trap 'if [ "${POINTBASE_PID}" != "" ]; then
        kill -9 ${POINTBASE_PID}
        unset POINTBASE_PID
        fi' 2
}