次に、in.named データサービス用の start_net メソッドの例を示します。
#! /bin/sh
#
#Copyright 13 Apr 1996 Sun Microsystems, Inc. All Rights Reserved.
#
#ident "@(#)innamed_start_net.sh 1.1 96/04/13 SMI"
#
# HA-in.named start_net method
ARGV0=`basename $0`
SYSLOG_FACILITY=`haget -f syslog_facility`
MASTERED_LOGICAL_HOSTS="$1"
if [ -z "$MASTERED_LOGICAL_HOSTS" ]; then
# This physical host does not currently master any logical hosts.
exit 0
fi
# Replace comma with space to form an sh word list:
MASTERED_LOGICAL_HOSTS="`echo $MASTERED_LOGICAL_HOSTS | tr ',' '`"
# Dynamically search the list of logical hosts which this physical
# host currently masters, to see if one of them is the logical host
# that HA-in.named uses.
MYLH=
for LH in $MASTERED_LOGICAL_HOSTS ; do
# Map logical hostname to administrative file system name:
PATHPREFIX_FS=`haget -f pathprefix $LH`
CONFIG="${PATHPREFIX_FS}/hainnamed/hainnamed.config"
if [ -f $CONFIG ]; then
MYLH=$LH
break
fi
done
if [ -z "$MYLH" ]; then
# This host does not currently master the logical host
# that HA-in.named uses.
exit 0
fi
# This host currently masters the logical host that HA-in.named uses, $MYLH
# See if in.named is already running, if so exit. (We must have
# started it on some earlier cluster reconfiguration when this
# physical host first took over mastery of the $MYLH logical host.)
# We determine whether in.named is already running by using the pmfadm
# command to query its status: if the query succeeds, it is already
# running.
if pmfadm -q hainnamed >/dev/null 2>&1 ; then
exit 0
fi
HA_INNAMED_DIR="`cat $CONFIG`"
if [ ! -d $HA_INNAMED_DIR ]; then
logger -p ${SYSLOG_FACILITY}.err ¥
"${ARGV0}: directory $HA_INNAMED_DIR missing or not mounted"
exit 1
fi
# We cd to the HA_INNAMED_DIR directory because the named.boot file
# contains the names of other files. By cd'ing, we permit all of
# those names to be relative names, relative to the current directory
cd $HA_INNAMED_DIR
if [ ! -s named.boot ]; then
logger -p ${SYSLOG_FACILITY}.err ¥
"${ARGV0}:file $HA_INNAMED_DIR/named.boot is missing or empty"
exit 1
fi
# Run the in.named daemon under the control of the Sun Cluster process
# monitory facility. Let it crash and restart up to 4 times an hour;
# if it crashes more often than that, the process monitor facility daemon
# will cease trying to restart it.
pmfadm -c hainnamed -n 4 -t 60 /usr/sbin/in.named -b named.boot
if [ $? -ne 0 ]; then
logger -p ${SYSLOG_FACILITY}.err ¥
"${ARGV0}: pmfadm -c of in.named failed"
exit 1
fi
exit 0
|