#! /bin/ksh
#
# --------------------------------------------------------------------------
# Licensed Materials - Property of IBM
#
#  5724-A60
#  5765-F36
#  (C) Copyright IBM Corporation 2001, 2004
#
# All Rights Reserved.
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
# PURPOSE: IM Scoring Setup of Oracle Cartridge
#          Shared libraries are expected to be in (AIX) /usr/opt/IMinerX/V8.2/lib
#                                                 (SunOS, Linux) /opt/IMinerX/V8.2/lib
#
# --------------------------------------------------------------------------

# Find directory for scoring libraries and cd to directory
# where the sql scripts are located.
case "$(uname -s)" in
*AIX*)   dll_dir=/usr/opt/IMinerX/V8.2/lib
         cd /usr/opt/IMinerX/V8.2/bin ;;
*SunOS*) dll_dir=/opt/IMinerX/V8.2/lib
         cd /opt/IMinerX/V8.2/bin ;;
*Linux*) dll_dir=/opt/IMinerX/V8.2/lib
         cd /opt/IMinerX/V8.2/bin ;;
    *) echo Error: Operating system found: $(uname -s). Supported are: AIX, SunOS, Linux
       exit ;;
esac

# Directory separator
dll_pre=/

# Extension for shared libraries
dll_ext=''

# Temporary directory (for log-file). Must have trailing slash
log_dir=/tmp/

echo "**********************************************"
echo "** IBM Intelligent Miner Scoring            **"
echo "** (C) Copyright IBM Corporation 2001, 2004 **"
echo "**                                          **"
echo "** Oracle Data Cartridge Setup              **"
echo "**                                          **"
echo "**********************************************"
echo
echo "Please enter logon information (Password for user SYS)."
echo "The cartridge will be created in the default database."

# Determine SQL*Plus version (8 or above)
# Version 8 differs in handling of empty command line parameters.
# Then call SQL*Plus script idm_setup.sql to perform cartridge setup

sqlplus -? | grep "Release 8" > /dev/null
if [ $? != 0 ]; then
  # Release 9/10
  sqlplus 'sys as sysdba' @idm_setup.sql $dll_dir $dll_pre "$dll_ext" $log_dir
else
  # Release 8
  sqlplus 'sys as sysdba' @idm_setup.sql $dll_dir $dll_pre \'$dll_ext\' $log_dir
fi

cd -

