PageRenderTime 172ms CodeModel.GetById 164ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 1ms

/ctdb/events.d/60.nfs

http://github.com/brinkman83/bashrc
Shell | 111 lines | 76 code | 22 blank | 13 comment | 13 complexity | 0789bfb773a7befa57f0f102ab5640ee MD5 | raw file
  1#!/bin/sh
  2# script to manage nfs in a clustered environment
  3
  4start_nfs() {
  5	/bin/mkdir -p $CTDB_BASE/state/nfs
  6	/bin/mkdir -p $CTDB_BASE/state/statd/ip
  7	/bin/mkdir -p $STATD_SHARED_DIRECTORY
  8	startstop_nfs stop
  9	startstop_nfs start
 10}
 11
 12reconfigure_nfs() {
 13	# always restart the lockmanager so that we start with a clusterwide
 14	# graceperiod when ip addresses has changed
 15	[ -x $CTDB_BASE/statd-callout ] && {
 16		$CTDB_BASE/statd-callout notify &
 17	} >/dev/null 2>&1
 18
 19}
 20
 21. $CTDB_BASE/functions
 22
 23service_name="nfs"
 24service_start="start_nfs"
 25service_stop="startstop_nfs stop"
 26service_reconfigure="reconfigure_nfs"
 27
 28loadconfig
 29
 30[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
 31
 32ctdb_start_stop_service
 33
 34case "$1" in 
 35     startup)
 36	ctdb_service_start
 37	;;
 38
 39     shutdown)
 40	ctdb_service_stop
 41	;;
 42
 43     takeip)
 44	ctdb_service_set_reconfigure
 45	touch $CTDB_BASE/state/statd/ip/$3
 46	;;
 47
 48     releaseip)
 49	ctdb_service_set_reconfigure
 50	/bin/rm -f $CTDB_BASE/state/statd/ip/$3
 51	;;
 52
 53     recovered)
 54	# if we have taken or released any ips we must 
 55	# restart the lock manager so that we enter a clusterwide grace period
 56	if ctdb_service_needs_reconfigure ; then
 57	    ctdb_service_reconfigure
 58	fi
 59	;;
 60
 61      monitor)
 62	if ctdb_service_needs_reconfigure ; then
 63	    ctdb_service_reconfigure
 64	    exit 0
 65	fi
 66
 67	# check that statd responds to rpc requests
 68	# if statd is not running we try to restart it
 69	rpcinfo -u localhost 100024 1 > /dev/null || {
 70		RPCSTATDOPTS=""
 71		[ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
 72		[ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
 73		[ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
 74		rpc.statd $RPCSTATDOPTS 
 75		echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
 76	}
 77
 78
 79	# check that NFS responds to rpc requests
 80	ctdb_check_rpc "NFS" 100003 3
 81
 82	# and that its directories are available
 83	[ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
 84	    exportfs | grep -v '^#' | grep '^/' |
 85	    sed -e 's/[[:space:]]*[^[:space:]]*$//' |
 86	    ctdb_check_directories
 87	} || exit $?
 88
 89	# check that lockd responds to rpc requests
 90	ctdb_check_rpc "lockd" 100021 1
 91	echo "$STATD_SHARED_DIRECTORY" | ctdb_check_directories "statd" || \
 92	    exit $?
 93
 94	# mount needs special handling since it is sometimes not started
 95	# correctly on RHEL5
 96	rpcinfo -u localhost 100005 1 > /dev/null || {
 97		echo "ERROR: MOUNTD is not running. Trying to restart it."
 98		RPCMOUNTDOPTS=""
 99		[ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
100		killall -q -9 rpc.mountd
101		rpc.mountd $RPCMOUNTDOPTS &
102		exit 1
103	}
104       	;;
105
106    *)
107	ctdb_standard_event_handler "$@"
108	;;
109esac
110
111exit 0