Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > aec460a90bd5c896caaa1d0425124291 > files > 14

ctdb-1.0.114-2.fc15.i686.rpm

#!/bin/sh
# script to manage nfs in a clustered environment

start_nfs() {
	/bin/mkdir -p $CTDB_BASE/state/nfs
	/bin/mkdir -p $CTDB_BASE/state/statd/ip
	/bin/mkdir -p $STATD_SHARED_DIRECTORY
	startstop_nfs stop
	startstop_nfs start
}

reconfigure_nfs() {
	# always restart the lockmanager so that we start with a clusterwide
	# graceperiod when ip addresses has changed
	[ -x $CTDB_BASE/statd-callout ] && {
		$CTDB_BASE/statd-callout notify &
	} >/dev/null 2>&1

}

. $CTDB_BASE/functions

service_name="nfs"
service_start="start_nfs"
service_stop="startstop_nfs stop"
service_reconfigure="reconfigure_nfs"

loadconfig

[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0

ctdb_start_stop_service

case "$1" in 
     startup)
	ctdb_service_start
	;;

     shutdown)
	ctdb_service_stop
	;;

     takeip)
	ctdb_service_set_reconfigure
	touch $CTDB_BASE/state/statd/ip/$3
	;;

     releaseip)
	ctdb_service_set_reconfigure
	/bin/rm -f $CTDB_BASE/state/statd/ip/$3
	;;

     recovered)
	# if we have taken or released any ips we must 
	# restart the lock manager so that we enter a clusterwide grace period
	if ctdb_service_needs_reconfigure ; then
	    ctdb_service_reconfigure
	fi
	;;

      monitor)
	if ctdb_service_needs_reconfigure ; then
	    ctdb_service_reconfigure
	    exit 0
	fi

	# check that statd responds to rpc requests
	# if statd is not running we try to restart it
	rpcinfo -u localhost 100024 1 > /dev/null || {
		RPCSTATDOPTS=""
		[ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
		[ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
		[ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
		rpc.statd $RPCSTATDOPTS 
		echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
	}


	# check that NFS responds to rpc requests
	[ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
	    ctdb_check_rpc "NFS" 100003 3
	}

	# and that its directories are available
	[ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
	    exportfs | grep -v '^#' | grep '^/' |
	    sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
	    ctdb_check_directories
	} || exit $?

	# check that lockd responds to rpc requests
	ctdb_check_rpc "lockd" 100021 1
	echo "$STATD_SHARED_DIRECTORY" | ctdb_check_directories "statd" || \
	    exit $?

	# mount needs special handling since it is sometimes not started
	# correctly on RHEL5
	rpcinfo -u localhost 100005 1 > /dev/null || {
		echo "ERROR: MOUNTD is not running. Trying to restart it."
		RPCMOUNTDOPTS=""
		[ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
		killall -q -9 rpc.mountd
		rpc.mountd $RPCMOUNTDOPTS &
		exit 1
	}
	# rquotad needs special handling since it is sometimes not started
	# correctly on RHEL5
	# this is not a critical service so we dont flag the node as unhealthy
	rpcinfo -u localhost 100011 1 > /dev/null || {
		echo "ERROR: RQUOTAD is not running. Trying to restart it."
		RPCRQUOTADOPTS=""
		[ -n "$RQUOTAD_PORT" ] && RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
		killall -q -9 rpc.rquotad
		rpc.rquotad $RPCRQUOTADOPTS &
	}
       	;;

    *)
	ctdb_standard_event_handler "$@"
	;;
esac

exit 0