2 # script to manage nfs in a clustered environment
8 [ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
9 [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
14 PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
20 /bin/mkdir -p $CTDB_BASE/state/nfs
21 /bin/mkdir -p $CTDB_BASE/state/statd/ip
22 /bin/mkdir -p $STATD_SHARED_DIRECTORY
24 # make sure nfs is stopped before we start it, or it may get a bind error
37 echo $ip >> $CTDB_BASE/state/statd/restart
39 # having a list of what IPs we have allows statd to do the right
40 # thing via $CTDB_BASE/statd-callout
41 touch $CTDB_BASE/state/statd/ip/$ip
50 echo $ip >> $CTDB_BASE/state/statd/restart
51 /bin/rm -f $CTDB_BASE/state/statd/ip/$ip
56 # if no IPs have changed then don't need to restart statd
57 [ -f $CTDB_BASE/state/statd/restart ] || exit 0;
59 # always restart the lockmanager so that we start with a clusterwide
60 # graceperiod when ip addresses has changed
61 [ -x $CTDB_BASE/statd-callout ] && {
62 $CTDB_BASE/statd-callout notify &
65 /bin/rm -f $CTDB_BASE/state/statd/restart
69 # check that statd responds to rpc requests
70 # if statd is not running we try to restart it
71 rpcinfo -u localhost 100024 1 > /dev/null || {
73 [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
74 [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
75 [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
76 rpc.statd $RPCSTATDOPTS
77 echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
81 # check that NFS responds to rpc requests
82 ctdb_check_rpc "NFS" 100003 3
84 # and that its directories are available
85 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
86 nfs_dirs=$(exportfs | grep -v '^#' | grep '^/' | awk {'print $1;'})
87 ctdb_check_directories "nfs" $nfs_dirs
90 # check that lockd responds to rpc requests
91 ctdb_check_rpc "lockd" 100021 1
92 ctdb_check_directories "statd" $STATD_SHARED_DIRECTORY
94 # mount needs special handling since it is sometimes not started
96 rpcinfo -u localhost 100005 1 > /dev/null || {
97 echo "ERROR: MOUNTD is not running. Trying to restart it."
99 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
100 killall -q -9 rpc.mountd
101 rpc.mountd $RPCMOUNTDOPTS &