#!/bin/sh
case $ORACLE_HOME in
    "")
    # Get the dir of excecutable, if ORACLE_HOME is not set
    CMDDIR=`dirname $0`

    if [ "$CMDDIR" = "." ]; then
        CMDDIR=`pwd`;
    fi

    # Replace relative path with fully qualified path.
    if [ ! "`echo $CMDDIR|grep '^/'`" ]; then
        CMDDIR=`pwd`/$CMDDIR;
    fi

    # Set ORACLE_HOME
    ORACLE_HOME=$CMDDIR/..
    export ORACLE_HOME
esac

# make sure only user can read their wallets. 
umask 77

unset ORA_SEC_WLT

# Unset any existing JAVA_HOME variable to ensure that only
# the JRE we want to use is used.
unset JAVA_HOME

# External Directory Variables set by the Installer 
#JRE_HOME=/oracle/EPP/11203/jdk/jre/
#JLIBDIR=/oracle/EPP/11203/jlib
JRE_HOME=$ORACLE_HOME/jdk
JLIBDIR=$ORACLE_HOME/jlib

#Set App Component  Path
PKI_JAR=$JLIBDIR/oraclepki.jar
OJPSE_JAR=$ORACLE_HOME/encryption/jlib/ojpse.jar
OSDT_CORE_JAR=$JLIBDIR/osdt_core.jar
OSDT_CERT_JAR=$JLIBDIR/osdt_cert.jar
EMMA_JAR=$ORACLE_HOME/ldap/test/lib/emma.jar

# Get the platform
PLATFORM=`uname`

# Some platforms may need other JVM environment variables set
# or unset as appropriate.
case $PLATFORM in "AIX")
   JAVA_COMPILER=NONE
   export JAVA_COMPILER
esac

# Linux platform uses native threads.
SET_DEFAULT=YES
case $PLATFORM in "Linux")
   SET_DEFAULT=NO
   THREADS_FLAG=native 
   export THREADS_FLAG
esac
case $SET_DEFAULT in "YES")
#  we only use green threads for the other platforms
   THREADS_TYPE=green_threads
   export THREADS_TYPE
esac

# Set the shared library path for JNI shared libraries
# A few platforms use an environment variable other than LD_LIBRARY_PATH
SET_DEFAULT_VAR=YES
SLLIBDIRNAME=lib

# for Sparc64, HP-PA, HPI invoke java with -d64 option to run in 64-bit mode.
JAVAMODE=
# for specific platforms reset variables and set others as needed.
case $PLATFORM in "HP-UX")
   JAVAMODE=-d64
esac
case $PLATFORM in "AIX")
   SET_DEFAULT_VAR=NO
   LIBPATH=$ORACLE_HOME/$SLLIBDIRNAME:$ORACLE_HOME/network/$SLLIBDIRNAME:$LIBPATH
   export LIBPATH
esac
case $PLATFORM in "SunOS")
   PLATFORM_ARCH=`uname -p`
   case $PLATFORM_ARCH in "sparc")
       JAVAMODE=-d64
   esac
esac
# if still selected, set the default variable name:LD_LIBRARY_PATH.
case $SET_DEFAULT_VAR in "YES")
   LD_LIBRARY_PATH=$ORACLE_HOME/$SLLIBDIRNAME:$ORACLE_HOME/network/$SLLIBDIRNAME:$LD_LIBRARY_PATH
   export LD_LIBRARY_PATH
esac

# Turn off keboard echo so that we don't display the password characters.
# stty -echo 2>&-

# Run the wallet manager tool
if [ "$CODECOV" = TRUE ]
   then $JRE_HOME/bin/java $JAVAMODE -cp $PKI_JAR:$EMMA_JAR:$OSDT_CORE_JAR:$OSDT_CERT_JAR oracle.security.pki.OracleSecretStoreTextUI "$@"
   else $JRE_HOME/bin/java $JAVAMODE -cp $PKI_JAR:$OSDT_CORE_JAR:$OSDT_CERT_JAR oracle.security.pki.OracleSecretStoreTextUI "$@"
fi
