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 /bin/rm -f $CTDB_BASE/state/statd/statd.restart >/dev/null 2>/dev/null
26 # make sure nfs is stopped before we start it, or it may get a bind error
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 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 statd responds to rpc requests
72 # if statd is not running we try to restart it once and wait
73 # for the next monitoring event to verify if it is running or not
74 # if it still fails we fail and mark the node as UNHEALTHY
75 if [ -f $CTDB_BASE/state/statd/statd.restart ]; then
76 # statd was restarted, see if it came up ok
77 rpcinfo -u localhost 100024 1 > /dev/null || {
78 echo "ERROR: Failed to restart STATD"
81 echo "STATD successfully restarted."
82 /bin/rm -f $CTDB_BASE/state/statd/statd.restart
84 rpcinfo -u localhost 100024 1 > /dev/null || {
86 [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
87 [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
88 [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
89 rpc.statd $RPCSTATDOPTS
90 echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
91 touch $CTDB_BASE/state/statd/statd.restart
97 # check that NFS responds to rpc requests
98 ctdb_check_rpc "NFS" 100003 3
100 # and that its directories are available
101 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
102 nfs_dirs=$(exportfs | grep -v '^#' | grep '^/' | awk {'print $1;'})
103 ctdb_check_directories "nfs" $nfs_dirs
106 # check that lockd responds to rpc requests
107 ctdb_check_rpc "lockd" 100021 1
108 ctdb_check_directories "statd" $STATD_SHARED_DIRECTORY
110 # mount needs special handling since it is sometimes not started
112 rpcinfo -u localhost 100005 1 > /dev/null || {
113 echo "ERROR: MOUNTD is not running. Trying to restart it."
115 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
116 killall -q -9 rpc.mountd
117 rpc.mountd $RPCMOUNTDOPTS &