#!/bin/sh
# Copyright(c) Sybase, Inc.
#
# This file defines the environment variable for UAF and its tools.
# All environment variables defined in this file must NOT reference
# or need to reference node specific subdirectories.
#
UA_ENV_STATUS=
#
# Determine the operating system and other variables to make some
# choices about JRE Selection and shared library locations
#

if [ -x "/bin/uname" ]; then
  nodename=`/bin/uname -n`
  osname=`/bin/uname -s`
  osarch=`/bin/uname -m`
  osversion=`/bin/uname -r`
else
  if [ -x "/usr/bin/uname" ]; then
    nodename=`/usr/bin/uname -n`
    osname=`/usr/bin/uname -s`
    osarch=`/usr/bin/uname -m`
    osversion=`/usr/bin/uname -r`
  else
    echo Failed to discover operating environment
    UA_ENV_STATUS=1
    exit 1
  fi
fi

if [ -z "$SYBASE_JRE6" ]; then
    echo The $osname $osarch platform requires one of the following environment variables
    echo to be set: SYBASE_JRE6
    UA_ENV_STATUS=1
    exit 1;
fi

SYBASE_JRE=$SYBASE_JRE6

# strip domain name from the node name

if [ -x "/bin/awk" ]; then
  AWK=/bin/awk
else
  if [ -x "/usr/bin/awk" ]; then
    AWK=/usr/bin/awk
  else
    echo Failed to find awk executable
    UA_ENV_STATUS=1
    exit 1
  fi
fi

if [ -x "/bin/domainname" ]; then
  DOMAINNAME=`/bin/domainname`
else
  if [ -x "/usr/bin/domainname" ]; then
    DOMAINNAME=`/usr/bin/domainname`
  else
    echo Failed to find domainname executable
    UA_ENV_STATUS=1
    exit 1
  fi
fi

nodename=`echo $nodename | $AWK -F"."$DOMAINNAME '{print $1}'`

if [ ${SYBASE_UA} ]; then
  echo ""
else
  echo SYBASE_UA environment variable not set
  UA_ENV_STATUS=1
  exit 1
fi

bitwidth=

if [ $osname = "SunOS" ]; then
    bitwidth=-d64
fi

if [ $osname = "HP-UX" ]; then
    bitwidth=-d64
fi

POLICY=${SYBASE_UA}/conf/java.policy

# Save the original $SYBASE_UA as SYBASE_UA_TOPLEVEL
SYBASE_UA_TOPLEVEL=${SYBASE_UA}

#
# Optional:
# Only if you are using your own JINI lookup service,
# you need to modify the following JINI related settings.
# Modify JINI_HOME to point to your own JINI root directory.
#
UA_LOG_HOME=${SYBASE_UA}/log
JINI_HOME=${SYBASE_UA}/thirdparty/jini1_2_1_001
JINI_LOG=${UA_LOG_HOME}/jini.log
RMID_LOG=${UA_LOG_HOME}/rmid.log
CLASS_SERVER_PORT=9092
RMID_PORT=9095

POLICY=${SYBASE_UA}/conf/java.policy

UA_ENV_STATUS=0
