#!/sbin/sh
#
# Copyright 1997-1999 by Sun Microsystems, Inc.
# All rights reserved.
#
# @(#)nhprobe 1.12     02/02/01 SMI
#


USER_FILE=/etc/opt/SUNWcgha/nhcmm.conf
PROBE_DIR=/opt/SUNWcgha/sbin
INSTALL_FILE=/etc/opt/SUNWcgha/not_configured

# Make the runtime linker load all shared objects at startup
LD_BIND_NOW=yes
export LD_BIND_NOW


if [ -f "$INSTALL_FILE" ]
then
	echo "[nhcmm] $INSTALL_FILE present"
	echo " => no action taken"
	exit 0
fi

# inline the user modifiable config file
.  $USER_FILE

# Daemonize nhprobed
PROBE_OPTION=" -d"

case "$1" in
'start')			
	echo "starting cgtp probe ($PROBE_DIR/nhprobed) \c"
	CGHA_COMPONENT_NAME="CMM probe"
	export CGHA_COMPONENT_NAME

	if [ -n "$CMM_NIC0" ]; then
	    PROBE_OPTION="$PROBE_OPTION -o nic0=$CMM_NIC0"
        fi
        
	if [ -n "$CMM_NIC1" ]; then
	    PROBE_OPTION="$PROBE_OPTION -o nic1=$CMM_NIC1"
        fi
        
	if [ "$CMM_USE_CGTP" != YES ]; then
	    PROBE_OPTION="$PROBE_OPTION -o noroute"
	fi

	$PROBE_DIR/nhprobed $PROBE_OPTION

	if [ $? -eq 0 ] ; then
		echo "done."
	else
		echo "failed."
	fi
	;;

'stop')
	for prog in nhprobed; do
		/usr/bin/pkill -x -u 0 $prog
	done
	;;

*)
	echo "Usage: $0 { start | stop }"
	exit 1
	;;
esac

exit 0
