#!/bin/sh 
#    Copyright (c) 2003 Oracle Corporation. All rights reserved.
#
#    This is a simple script used to start the Oracle Calendar (tm) client
#    for Unix


OCALENDAR_ROOT=/var/tmp/mit-techtime-9.0.4.2-4-buildroot/usr/local/OracleCalendar
#Track error state in the script
OC_STATUS=1

if [ `uname -s` = Linux ] 
then
	export LC_ALL=en_US
fi

# If OCALENDAR_ROOT is defined then use its value. If not then try to guess the
# install path from the command line.

OCALENDAR_ROOT=${OCALENDAR_ROOT:-`dirname $0`}

if [ $OCALENDAR_ROOT = "." ]
then
    OCALENDAR_ROOT=$PWD
fi

#OCALENDAR_ROOT should not include the bin directory

if [ `basename $OCALENDAR_ROOT` = "bin" ]
then
    OCALENDAR_ROOT=`dirname $OCALENDAR_ROOT`
fi

#Look for the executable in a bin subdirectory of OCALENDAR_ROOT

if [  ! -x $OCALENDAR_ROOT/bin/Ocal  ]
then

    #Last chance. Check the default install path
    OCALENDAR_ROOT=/usr/local/OracleCalendar

    if [  ! -x $OCALENDAR_ROOT/bin/Ocal  ]
    then
        OC_STATUS=0
    fi
fi

if [ $OC_STATUS = 0 ]
then
    echo "Set the environment variable OCALENDAR_ROOT to point to the installation directory before running this script"
fi

#    Set the path to the help files

if [ $OC_STATUS = 1 ]
then
    #Need an absolute path to the help files

    case $OCALENDAR_ROOT in
    .*)
       OCALENDAR_ROOT=$PWD/${OCALENDAR_ROOT};;
    *);;
    esac

    OCAL_HELP_DIR=${OCALENDAR_ROOT}/help/en_US
    export OCAL_HELP_DIR
fi

#
#    Ensure that the application looks in the install directory first
#    for any Oracle Corporation(tm) shared libraries
#

if [ $OC_STATUS = 1 ]
then
    OCAL_LIB_PATCH=$OCALENDAR_ROOT/lib/core:$OCALENDAR_ROOT/lib/ACE:$OCALENDAR_ROOT/lib/Oracle

    if [ -z "$LD_LIBRARY_PATH" ]
    then
        LD_LIBRARY_PATH=$OCAL_LIB_PATCH
    else
        LD_LIBRARY_PATH=$OCAL_LIB_PATCH:${LD_LIBRARY_PATH}
    fi

    export LD_LIBRARY_PATH

    echo Starting Oracle Calendar for `uname -s`

# Run the executable 
    exec ${OCALENDAR_ROOT}/bin/Ocal $*
fi
