#!/bin/sh
# *************************************************************************
# This script is used to set up your environment for SPECjAppServer running with
# WebLogic Server. It sets the following variables: 
#
# *************************************************************************

WL_HOME="/home/spec/bea/weblogic81"
JAVA_HOME="/opt/java1.4"
XERCES_JAR="../../jars/xerces.jar"
export WL_HOME JAVA_HOME XERCES_JAR

JDBC_CLASSPATH=/home/spec/newjdbc/wlbase.jar:/home/spec/newjdbc/wlutil.jar:/home/spec/newjdbc/wloracle.jar
export JDBC_CLASSPATH

WL_DOMAIN=specdomain
WL_SERVER=spec11
WL_SERVERIP=spec11
WL_SERVERPORT=7001
export WL_DOMAIN WL_SERVER WL_SERVERIP WL_SERVERPORT

WL_USER=system
WL_PW=weblogic
STARTMODE=true
export WL_USER WL_PW STARTMODE

JAVA_OPTIONS="-Xmx2400m -Xms2400m -Xmn768m -Xoptgc -XX:+ForceMmapReserved -XX:PermSize=64m -XX:SurvivorRatio=20 -XX:-UseHighResolutionTimer -XX:SchedulerPriorityRange=SCHED_RTPRIO -XX:-StackTraceInThrowable"
WL_OPTIONS="-Dweblogic.management.discover=false -Dweblogic.SocketReaders=1"
export JAVA_OPTIONS WL_OPTIONS

# Check that the WebLogic classes are where we expect them to be
if [ ! -f "${WL_HOME}/server/lib/weblogic.jar" ]; then
  echo 
  echo "The WebLogic Server wasn't found in directory ${WL_HOME}/server."
  echo "Please edit your script so that the WL_HOME variable points"
  echo "to the WebLogic installation directory."

# Check that java is where we expect it to be
elif [ ! -d "${JAVA_HOME}/bin" ]; then
  echo 
  echo "The JDK wasn't found in directory ${JAVA_HOME}."
  echo "Please edit your script so that the JAVA_HOME variable"
  echo "points to the location of your JDK."

else
# Grab some file descriptors.
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

# Set first two positional parameters to SERVER_NAME and ADMIN_URL
if [ -n "${1}" -a "${SERVER_NAME}" = "" ]; then
  SERVER_NAME="${1}"
fi

if [ -n "${2}" -a "${ADMIN_URL}" = "" ]; then
  ADMIN_URL="${2}"
fi

# Figure out how to use our shared libraries
case `uname -s` in
AIX)
  if [ -n "${LIBPATH}" ]; then
    LIBPATH="${LIBPATH}:${WL_HOME}/server/lib/aix:${WL_HOME}/server/lib/aix/oci920_8"
  else
    LIBPATH="${WL_HOME}/server/lib/aix:${WL_HOME}/server/lib/aix/oci920_8"
  fi
  PATH="${WL_HOME}/server/lib/aix:${PATH}"
  export LIBPATH PATH
  export AIXTHREAD_SCOPE=S
  export AIXTHREAD_MUTEX_DEBUG=OFF
  export AIXTHREAD_RWLOCK_DEBUG=OFF
  export AIXTHREAD_COND_DEBUG=OFF
  echo "LIBPATH=${LIBPATH}"
;;
HP-UX)
  if [ -n "${SHLIB_PATH}" ]; then
    SHLIB_PATH="${SHLIB_PATH}:${WL_HOME}/server/lib/IPF32:${WL_HOME}/server/lib/IPF32/oci920_8"
  else
    SHLIB_PATH="${WL_HOME}/server/lib/IPF32:${WL_HOME}/server/lib/IPF32/oci920_8"
  fi
  PATH="${WL_HOME}/server/lib/IPF32:${PATH}"
  export SHLIB_PATH PATH
  echo "SHLIB_PATH=${SHLIB_PATH}"
;;
IRIX)
  if [ -n "${LD_LIBRARY_PATH}" ]; then
    LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${WL_HOME}/server/lib/irix"
  else
    LD_LIBRARY_PATH="${WL_HOME}/server/lib/irix"
  fi
  PATH="${WL_HOME}/server/lib/irix:${PATH}"
  export LD_LIBRARY_PATH PATH
  echo "LD_LIBRARY_PATH=${LD_LIBRARY_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}/oci920_8"
  else
    LD_LIBRARY_PATH="${WL_HOME}/server/lib/linux/${arch}:${WL_HOME}/server/lib/linux/${arch}/oci920_8"
  fi
  PATH="${WL_HOME}/server/lib/linux:${PATH}"
  export LD_LIBRARY_PATH PATH
  echo "LD_LIBRARY_PATH=${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
  PATH="${WL_HOME}/server/lib/tru64unix:${PATH}"
  export LD_LIBRARY_PATH PATH
  echo "LD_LIBRARY_PATH=${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/oci920_8"
  else
    LD_LIBRARY_PATH="${WL_HOME}/server/lib/solaris:${WL_HOME}/server/lib/solaris/oci920_8"
  fi
  PATH="${WL_HOME}/server/lib/solaris:${PATH}"
  export LD_LIBRARY_PATH PATH
  echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
  if [ "${JAVA_VM}" = "" ]
  then
    JAVA_VM=-server
  fi
;;
Windows_NT*)
  if [ "${JAVA_VM}" = "" ]
  then
    JAVA_VM=-hotspot
  fi
  PATHSEP=\;
  CLASSPATHSEP=\;
;;
CYGWIN*)
  if [ "${JAVA_VM}" = "" ]
  then
    JAVA_VM=-hotspot
  fi
  CLASSPATHSEP=\;
;;
*)
  echo "$0: Don't know how to set the shared library path for `uname -s`.  "
esac


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

set -x
CLASSPATH="${JAVA_HOME}/lib/tools.jar${CLASSPATHSEP}${XERCES_JAR}${CLASSPATHSEP}${JDBC_CLASSPATH}${CLASSPATHSEP}${WL_HOME}/server${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.jar${CLASSPATHSEP}${CLASSPATH}"
export CLASSPATH
set +x

# If we are on Cygnus we need to turn <letter>:/ in the path to //<letter>/
if [ `uname -s` = "CYGWIN32/NT" ]; then
  WL_HOME=`echo $WL_HOME | sed "s#\([a-zA-Z]\):#//\1#g"`
  JAVA_HOME=`echo $JAVA_HOME | sed "s#\([a-zA-Z]\):#//\1#g"`
fi

set -x
PATH="${WL_HOME}/server/bin${PATHSEP}${JAVA_HOME}/jre/bin${PATHSEP}${JAVA_HOME}/bin${PATHSEP}${PATH}"
export PATH
set +x

echo 
echo "Your environment has been set."

fi
