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
10 echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
14 # always restart the lockmanager so that we start with a clusterwide
15 # graceperiod when ip addresses has changed
16 [ -x $CTDB_BASE/statd-callout ] && {
17 $CTDB_BASE/statd-callout notify &
22 . $CTDB_BASE/functions
25 service_start="start_nfs"
26 service_stop="startstop_nfs stop"
27 service_reconfigure="reconfigure_nfs"
31 [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
33 ctdb_start_stop_service
45 ctdb_service_set_reconfigure
46 touch $CTDB_BASE/state/statd/ip/$3
50 ctdb_service_set_reconfigure
51 /bin/rm -f $CTDB_BASE/state/statd/ip/$3
55 # if we have taken or released any ips we must
56 # restart the lock manager so that we enter a clusterwide grace period
57 if ctdb_service_needs_reconfigure ; then
58 ctdb_service_reconfigure
63 if ctdb_service_needs_reconfigure ; then
64 ctdb_service_reconfigure
70 # check that statd responds to rpc requests
71 # if statd is not running we try to restart it
72 rpcinfo -u localhost 100024 1 > /dev/null || {
74 [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
75 [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
76 [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
77 rpc.statd $RPCSTATDOPTS
78 echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
82 # check that NFS responds to rpc requests
83 [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
84 (ctdb_check_rpc "NFS" 100003 3)
86 echo "Trying to restart NFS service"
92 # and that its directories are available
93 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
94 exportfs | grep -v '^#' | grep '^/' |
95 sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
96 ctdb_check_directories
99 # check that lockd responds to rpc requests
100 ctdb_check_rpc "lockd" 100021 1
101 echo "$STATD_SHARED_DIRECTORY" | ctdb_check_directories "statd" || \
104 # mount needs special handling since it is sometimes not started
106 rpcinfo -u localhost 100005 1 > /dev/null || {
107 echo "ERROR: MOUNTD is not running. Trying to restart it."
109 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
110 killall -q -9 rpc.mountd
111 rpc.mountd $RPCMOUNTDOPTS &
114 # rquotad needs special handling since it is sometimes not started
116 # this is not a critical service so we dont flag the node as unhealthy
117 rpcinfo -u localhost 100011 1 > /dev/null || {
118 echo "ERROR: RQUOTAD is not running. Trying to restart it."
120 [ -n "$RQUOTAD_PORT" ] && RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
121 killall -q -9 rpc.rquotad
122 rpc.rquotad $RPCRQUOTADOPTS &
127 ctdb_standard_event_handler "$@"