#!/bin/ksh
#
#pragma ident   "@(#)monreconfig.sh 1.2     00/10/30"
#Copyright (C) 1997 Sun Microsystems, Inc.
#
#
 
# monreconfig - SunCluster rpc Monitory Framework component
#
# Input:
#               All environment variables like "currnodes"/
#               "allnodes"/"localnodeid", CURRSTEP
#
# Action:       Run Reconfiguration Programs based on current
#               "cmmstepN"|"cmmabort"|"cmmstart"|"cmmreturn".
#
# Output:       Return 0 if success.
#               Return 1 if failure
#               Return 200 if reconfigurtion program result is to
#               be ignored.
 
# should be used only the reconf_framework.
pre="SUNWcluster.reconf.monitor"
 
RECONF_SCRIPTS=${RECONF_SCRIPTS:-/opt/SUNWcluster/etc/reconf/scripts}
CLUSTERBIN=${CLUSTERBIN:-/opt/SUNWcluster/bin/}
CLUSTERVAR=${CLUSTERVAR:-/var/opt/SUNWcluster/}
CLUSTERETC=${CLUSTERETC:-/etc/opt/SUNWcluster/}

##########################################################################
#
# function monstep1_cmd
#

function monstep1_cmd
{
# If we are starting and monitor_rpcbind is already running, kill it and
# then restart.
pids=$(/usr/bin/ps -ef | /usr/bin/grep -w monitor_rpcbind | \
                /usr/bin/grep -v grep | /usr/bin/awk ' { print $2 } ')
if [ ! -z ${pids} ]; then
	kill -15 ${pids}
fi

CONF_FILE=/etc/opt/SUNWcluster/conf/dflt_sched_class
DFLT_CLASS=TS

if [ -f ${CONF_FILE} ] ; then
        DFLT_CLASS=`cat ${CONF_FILE}`
fi

/bin/priocntl -c ${DFLT_CLASS} -e ${CLUSTERBIN}/monitor_rpcbind &

}

###########################################################################
#
# function monstop_cmd
#

function monstop_cmd
{
pids=$(/usr/bin/ps -ef | /usr/bin/grep -w monitor_rpcbind | \
                /usr/bin/grep -v grep | /usr/bin/awk ' { print $2 } ')
if [ ! -z ${pids} ]; then
	kill -15 ${pids}
fi
}


case ${CURRSTEP} in
  cmmabort | stopnode | cmmreturn)
	  monstop_cmd ;;
  cmmstep12 )
	  monstep1_cmd ;;
  *) ;;
esac

exit 0
