2 # script to manage nfs in a clustered environment
5 /bin/mkdir -p $CTDB_VARDIR/state/nfs
6 /bin/mkdir -p $CTDB_VARDIR/state/statd/ip
9 echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
12 . $CTDB_BASE/functions
15 service_start="start_nfs"
16 service_stop="startstop_nfs stop"
20 ctdb_start_stop_service
24 # read statd from persistent database
28 mkdir -p $CTDB_VARDIR/state/statd
29 touch $CTDB_VARDIR/state/statd/update-trigger
37 ctdb_service_set_reconfigure
41 ctdb_service_set_reconfigure
45 if ctdb_service_needs_reconfigure ; then
46 ctdb_service_reconfigure
52 # check that statd responds to rpc requests
53 # if statd is not running we try to restart it
54 rpcinfo -u localhost 100024 1 > /dev/null || {
56 [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
57 [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
58 [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
59 rpc.statd $RPCSTATDOPTS
60 echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
64 # check that NFS responds to rpc requests
65 [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
66 (ctdb_check_rpc "NFS" 100003 3)
68 echo "Trying to restart NFS service"
74 # and that its directories are available
75 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
76 exportfs | grep -v '^#' | grep '^/' |
77 sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
78 ctdb_check_directories
81 # check that lockd responds to rpc requests
82 (ctdb_check_rpc "lockd" 100021 1)
84 echo "Trying to restart lock manager service"
86 startstop_nfslock restart
90 # mount needs special handling since it is sometimes not started
92 rpcinfo -u localhost 100005 1 > /dev/null || {
93 echo "ERROR: MOUNTD is not running. Trying to restart it."
95 [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
96 killall -q -9 rpc.mountd
97 rpc.mountd $RPCMOUNTDOPTS &
100 # rquotad needs special handling since it is sometimes not started
102 # this is not a critical service so we dont flag the node as unhealthy
103 rpcinfo -u localhost 100011 1 > /dev/null || {
104 echo "ERROR: RQUOTAD is not running. Trying to restart it."
106 [ -n "$RQUOTAD_PORT" ] && RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
107 killall -q -9 rpc.rquotad
108 rpc.rquotad $RPCRQUOTADOPTS &
111 # once every 60 seconds, update the statd state database for which
112 # clients need notifications
113 LAST_UPDATE=`stat --printf="%Y" $CTDB_VARDIR/state/statd/update-trigger`
114 CURRENT_TIME=`date +"%s"`
115 expr "$CURRENT_TIME" ">" "(" "$LAST_UPDATE" "+" "60" ")" >/dev/null 2>/dev/null
117 mkdir -p $CTDB_VARDIR/state/statd
118 touch $CTDB_VARDIR/state/statd/update-trigger
119 $CTDB_BASE/statd-callout updatelocal &
120 $CTDB_BASE/statd-callout updateremote &
125 # if the ips have been reallocated, we must restart the lockmanager
126 # across all nodes and ping all statd listeners
127 [ -x $CTDB_BASE/statd-callout ] && {
128 $CTDB_BASE/statd-callout notify &
132 ctdb_standard_event_handler "$@"