2 # script to manage nfs in a clustered environment
7 [ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
8 [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
13 PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
17 /bin/mkdir -p $CTDB_BASE/state/nfs
18 /bin/mkdir -p $CTDB_BASE/state/statd/ip
19 /bin/mkdir -p $STATD_SHARED_DIRECTORY
21 # make sure nfs is stopped before we start it, or it may get a bind error
22 service nfs stop > /dev/null 2>&1
23 service nfslock stop > /dev/null 2>&1
30 # shutting down nfs can take a while so put it in the background
32 service nfslock stop &
39 echo $ip >> $CTDB_BASE/state/statd/restart
41 # having a list of what IPs we have allows statd to do the right
42 # thing via $CTDB_BASE/statd-callout
43 /bin/touch $CTDB_BASE/state/statd/ip/$ip
52 echo $ip >> $CTDB_BASE/state/statd/restart
53 /bin/rm -f $CTDB_BASE/state/statd/ip/$ip
58 # always restart the lockmanager so that we start with a clusterwide
59 # graceperiod when ip addresses has changed
60 [ -x $CTDB_BASE/statd-callout ] && {
61 $CTDB_BASE/statd-callout notify &
64 /bin/rm -f $CTDB_BASE/state/statd/restart
68 # check that NFS responds to rpc requests
69 ctdb_check_rpc "NFS" 100003 3
71 # and that its directories are available
72 nfs_dirs=`grep -v '^#' < /etc/exports | cut -d' ' -f1`
73 ctdb_check_directories "nfs" $nfs_dirs
75 # check that lockd responds to rpc requests
76 ctdb_check_rpc "statd" 100024 1
77 ctdb_check_rpc "lockd" 100021 1
78 ctdb_check_directories "statd" $STATD_SHARED_DIRECTORY
80 # mount needs special handling since it is sometimes not started
82 rpcinfo -u localhost 100005 1 > /dev/null || {
83 echo "`date` ERROR: MOUNTD is not running. Trying to restart it."
85 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
86 killall -q -9 rpc.mountd
87 rpc.mountd $RPCMOUNTDOPTS &