#!/bin/sh
#
# Licensed Materials - Property of IBM
#
# 5724O4800
#
# (C) Copyright IBM Corp. 1994, 2004. All Rights Reserved
#
# US Government Users Restricted Rights - Use, duplication
# or disclosure restricted by GSA ADP Schedule Contract
# with IBM Corp.
#
#
# Probe script - runs the correct probe for the current OS
#
# 5.50.78
#

#######################################
# Find nco_common
NCO_COMMON=`dirname $0`/../bin/nco_common

# Check for nco_common, and load if found
if [ ! -f "$NCO_COMMON" ]; then
        echo "Cannot find nco_common" 1>&2
        exit 1
fi
. $NCO_COMMON

# do NOT Set platform variables, as we need XPG_SUS_ENV to be unset for 
# probes/tsms
#f_SET_PLATFORM_VARIABLES

#
# environment variables that this shell script sets/changes:
#
export OMNIHOME OMNISERVER OMNIUSER OMNIPASSWD

#
# What program are we attempting to run ?
#
PROGRAM=`basename $0`

#
# Check the script name - if nco_probe is being run as itself it does nothing
#
if [ $PROGRAM = nco_probe ]; then
	exit 0
fi

#
# Can we run this probe ?
#
if [ -x $OMNIHOME/platform/$ARCH/probes64/$PROGRAM -a "64" = "$KERN_ARCH" ]
then
	bin=$OMNIHOME/platform/$ARCH/probes64/$PROGRAM
else
	if [ -x $OMNIHOME/probes/$ARCH/$PROGRAM ]
	then
		bin=$OMNIHOME/probes/$ARCH/$PROGRAM
	else
		err "Not installed for $ARCH"
	fi
fi

#
# Execute probe
#
PROBENAME=`echo "$PROGRAM" |cut -d'_' -f3-`

# Set environment if file exists and is readable
if [ -r $OMNIHOME/probes/$ARCH/${PROGRAM}.env ]
then
	. $OMNIHOME/probes/$ARCH/${PROGRAM}.env
fi

for arg in ${*}; do
    case ${arg} in
    -check)
        java -cp "$OMNIHOME/bin/ConfigAnalyser.jar:$OMNIHOME/java/jars/jlog.jar:$OMNIHOME/probes/java/$PROBENAME.check.jar"  $NCO_JPROBE_JAVA_XFLAGS com.ibm.tivoli.netcool.integrations.configanalyser.ConfigAnalyser $OMNIHOME/probes/$ARCH/ $PROGRAM $*
        exit
        ;;
    esac
done
exec $bin "$@"
