#!/bin/ksh
#
#ident  "@(#)isprivatenet.ksh 1.1     01/07/18 SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#

# This script is used to check if the adapter_name, passed as $1 
# is supporting, and also is enabled, in
# Sun Cluster private interconnect.
# The script will first check what is the hostname this script is running on
# to determine the nodename, then check if the adapter_name is supporting
# SC private interconnect, and enabled, by running scstat -W command.
# If it is, the script will return 1, else return 0.

ADAPTER_NAME=$1
NODE_NAME=`/usr/bin/hostname`

/usr/cluster/bin/scstat -W | nawk '
BEGIN {
        file = "/tmp/scstat_output"
}
/^[ \t]*Transport/{
        print $3 >> file
        print $4 >> file
}'

# Make sure input adapter_name match exactly as shown in scstat output

/usr/xpg4/bin/grep -x $NODE_NAME:$ADAPTER_NAME /tmp/scstat_output  > /dev/null

# record the return value
RETURNVALUE=$?
/bin/rm -rf /tmp/scstat_output

if [ $RETURNVALUE -ne 0 ]
then
	#echo "Not Found $ADAPTER_NAME on $NODE_NAME enabled as SC private interconnect"
	return 0
else
	#echo "Found $ADAPTER_NAME on $NODE_NAME enabled as SC private interconnect"
	return 1
fi

