2 # script to manage nfs in a clustered environment
5 /bin/mkdir -p $CTDB_BASE/state/nfs
6 /bin/mkdir -p $CTDB_BASE/state/statd/ip
7 /bin/mkdir -p $STATD_SHARED_DIRECTORY
13 # always restart the lockmanager so that we start with a clusterwide
14 # graceperiod when ip addresses has changed
15 [ -x $CTDB_BASE/statd-callout ] && {
16 $CTDB_BASE/statd-callout notify &
21 . $CTDB_BASE/functions
24 service_start="start_nfs"
25 service_stop="startstop_nfs stop"
26 service_reconfigure="reconfigure_nfs"
30 [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
32 ctdb_start_stop_service
44 ctdb_service_set_reconfigure
45 touch $CTDB_BASE/state/statd/ip/$3
49 ctdb_service_set_reconfigure
50 /bin/rm -f $CTDB_BASE/state/statd/ip/$3
54 # if we have taken or released any ips we must
55 # restart the lock manager so that we enter a clusterwide grace period
56 if ctdb_service_needs_reconfigure ; then
57 ctdb_service_reconfigure
62 if ctdb_service_needs_reconfigure ; then
63 ctdb_service_reconfigure
67 # check that statd responds to rpc requests
68 # if statd is not running we try to restart it
69 rpcinfo -u localhost 100024 1 > /dev/null || {
71 [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
72 [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
73 [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
74 rpc.statd $RPCSTATDOPTS
75 echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
78 # check that NFS responds to rpc requests
79 [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
80 (ctdb_check_rpc "NFS" 100003 3)
82 echo "Trying to restart NFS service"
88 # and that its directories are available
89 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
90 exportfs | grep -v '^#' | grep '^/' |
91 sed -e 's/[[:space:]]*[^[:space:]]*$//' |
92 ctdb_check_directories
95 # check that lockd responds to rpc requests
96 (ctdb_check_rpc "lockd" 100021 1)
98 echo "Trying to restart lock manager service"
99 startstop_nfslock restart
103 echo "$STATD_SHARED_DIRECTORY" | ctdb_check_directories "statd" || \
106 # mount needs special handling since it is sometimes not started
108 rpcinfo -u localhost 100005 1 > /dev/null || {
109 echo "ERROR: MOUNTD is not running. Trying to restart it."
111 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
112 killall -q -9 rpc.mountd
113 rpc.mountd $RPCMOUNTDOPTS &
116 # rquotad needs special handling since it is sometimes not started
118 # this is not a critical service so we dont flag the node as unhealthy
119 rpcinfo -u localhost 100011 1 > /dev/null || {
120 echo "ERROR: RQUOTAD is not running. Trying to restart it."
122 [ -n "$RQUOTAD_PORT" ] && RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
123 killall -q -9 rpc.rquotad
124 rpc.rquotad $RPCRQUOTADOPTS &
129 ctdb_standard_event_handler "$@"