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 # if no IPs have changed then don't need to restart statd
59 [ -f $CTDB_BASE/state/statd/restart ] || exit 0;
61 # always restart the lockmanager so that we start with a clusterwide
62 # graceperiod when ip addresses has changed
63 [ -x $CTDB_BASE/statd-callout ] && {
64 $CTDB_BASE/statd-callout notify &
67 /bin/rm -f $CTDB_BASE/state/statd/restart
71 # check that NFS responds to rpc requests
72 ctdb_check_rpc "NFS" 100003 3
74 # and that its directories are available
75 nfs_dirs=$(grep -v '^#' < /etc/exports | awk {'print $1;'})
76 ctdb_check_directories "nfs" $nfs_dirs
78 # check that lockd responds to rpc requests
79 ctdb_check_rpc "statd" 100024 1
80 ctdb_check_rpc "lockd" 100021 1
81 ctdb_check_directories "statd" $STATD_SHARED_DIRECTORY
83 # mount needs special handling since it is sometimes not started
85 rpcinfo -u localhost 100005 1 > /dev/null || {
86 echo "`date` ERROR: MOUNTD is not running. Trying to restart it."
88 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
89 killall -q -9 rpc.mountd
90 rpc.mountd $RPCMOUNTDOPTS &