#!/bin/sh # script to manage nfs in a clustered environment . /etc/ctdb/functions loadconfig nfs [ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0 cmd="$1" shift PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH case $cmd in startup) mkdir -p /etc/ctdb/state/nfs # wait for all nfs exported directories to become available nfs_dirs=`grep -v '^#' < /etc/exports | cut -d' ' -f1` ctdb_wait_directories "NFS" $nfs_dirs # make sure nfs is stopped before we start it, or it may get a bind error service nfs stop > /dev/null 2>&1 service nfs start ;; shutdown) service nfs stop ;; releaseip) iface=$1 ip=$2 maskbits=$3 echo $ip >> /etc/ctdb/state/nfs/restart exit 0 ;; recovered) # restart NFS to ensure that all TCP connections to the released ip # are closed [ -f /etc/ctdb/state/nfs/restart ] && { ( service nfs status > /dev/null 2>&1 && service nfs restart > /dev/null 2>&1 ) & } > /dev/null 2>&1 /bin/rm -f /etc/ctdb/state/nfs/restart ;; monitor) # check that NFS responds to rpc requests ctdb_check_rpc "NFS" 100003 3 ctdb_check_rpc "mount" 100005 1 # and that its directories are available nfs_dirs=`grep -v '^#' < /etc/exports | cut -d' ' -f1` ctdb_check_directories "nfs" $nfs_dirs ;; esac exit 0