Sun Cluster 2.2 API Developer's Guide

2.2.3 stop_net Method for the in.named Data Service

The following is a sample stop_net method for the in.named data service.


#! /bin/sh
 #	Copyright 13 Apr 1996 Sun Microsystems, Inc. All Rights Reserved.
 #
 #ident "@(#)innamed_stop_net.sh 	1.1 96/04/13 SMI"
 #
 # HA-in.named stop_net method
 #
 ARGV0=`basename $0`
 SYSLOG_FACILITY=`haget -f syslog_facility`
 NOT_MASTERED_LOGICAL_HOSTS="$2"
 if [ -z "$NOT_MASTERED_LOGICAL_HOSTS" ]; then
 	# This physical host currently masters all logical hosts.
 	exit 0
 fi
 # Replace comma with space to have an sh word list:  # NOT_MASTERED_LOGICAL_HOSTS="`echo $NOT_MASTERED_LOGICAL_HOSTS |tr ',' ' '`"
 # Dynamically search the list of logical hosts that this physical
 # host should not master, to see if one of them is the logical host
 # that HA-in.named uses.  There are two cases to consider:
 # (1) This physical host gave up mastery of that logical host during
 # some earlier cluster reconfiguration.  In that case, the HA administrative
 # file system for the logical host will no longer be mounted so the
 # /HA administrative_file_system/hainnamed directory will not exist.
 # This method has no work to do, because the work got done during the
 # earlier cluster reconfiguration when this physical host first gave up
 # mastery of the logical host.
 # (2) This cluster reconfiguration is the one in which this physical
 # host is giving up mastery of the logical host.  In that case, the
 # administrative file system is still mounted when the stop_net method
 # is called and the /HA administrative_file_system/hainnamed directory
 # will exist.

 MYLH=
 for LH in $NOT_MASTERED_LOGICAL_HOSTS ; do
 	# Map logical hostname to pathprefix file system name:
 	PATHPREFIX_FS=`haget -f pathprefix $LH`

 	CONFIGDIR="${PATHPREFIX_FS}/hainnamed
 	if [ -d $CONFIGDIR ]; then
 			MYLH=$LH
 			break
 	fi
 done
 if [ -z "$MYLH" ]; then
 	# This host is not giving up mastery of the HA-in.named logical host
 	# during this cluster reconfiguration.
 	exit 0
 fi
 # This host is giving up mastery of the HA-in.named logical host, $MYLH
 # during this cluster reconfiguration.
 #
 # See if in.named is running, and if so, kill it. If it is not running,
 # then either we must have killed it during some earlier reconfiguration
 # when this physical host first gave up mastery of the logical host, or
 # this physical host has not had mastery of the logical host since it
 # last rebooted.
 #
 # Tell process monitor to kill the in.named daemon, if it was already
 # running.
 if pmfadm -q hainnamed; then
 	pmfadm -s hainnamed TERM	
 	if [ $? -ne 0 ]; then
 			logger ${SYSLOG_FACILITY}.err \
 				"${ARGV0}: pmfadm -s of in.named failed"
 			exit 1
 	fi
 fi

 exit 0