2 # script to manage nfs in a clustered environment
11 set_proc "sys/net/ipv4/tcp_tw_recycle" 1
12 touch "$service_state_dir/update-trigger"
18 service_reconfigure ()
22 # if the ips have been reallocated, we must restart the lockmanager
23 # across all nodes and ping all statd listeners
24 [ -x $CTDB_BASE/statd-callout ] && {
25 $CTDB_BASE/statd-callout notify &
31 [ "$NFS_SERVER_MODE" != "GANESHA" ] || exit 0
33 ctdb_setup_service_state_dir
35 ctdb_start_stop_service
37 is_ctdb_managed_service || exit 0
39 ctdb_service_check_reconfigure
43 # read statd from persistent database
54 ctdb_service_set_reconfigure
58 ctdb_service_set_reconfigure
62 # and that its directories are available
63 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
64 exportfs | grep -v '^#' | grep '^/' |
65 sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
66 ctdb_check_directories
71 # check that statd responds to rpc requests
72 # if statd is not running we try to restart it
73 # we only do this IF we have a rpc.statd command.
74 # For platforms where rpc.statd does not exist, we skip
75 # the check completely
77 which $p >/dev/null 2>/dev/null && {
78 if ctdb_check_rpc "STATD" 100024 1 >/dev/null ; then
79 (service_name="nfs_statd"; ctdb_counter_init)
82 cmd="${cmd}${STATD_HOSTNAME:+ -n }${STATD_HOSTNAME}"
83 cmd="${cmd}${STATD_PORT:+ -p }${STATD_PORT}"
84 cmd="${cmd}${STATD_OUTGOING_PORT:+ -o }${STATD_OUTGOING_PORT}"
86 service_name="nfs_statd"
88 ctdb_check_counter_limit 10 quiet >/dev/null
90 echo "$ctdb_check_rpc_out"
91 echo "Trying to restart STATD [$cmd]"
97 # check that NFS responds to rpc requests
98 [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
99 if ctdb_check_rpc "NFS" 100003 3 >/dev/null ; then
100 (service_name="nfs_knfsd"; ctdb_counter_init)
103 service_name="nfs_knfsd"
106 ctdb_check_counter_equal 2 || {
107 echo "Trying to restart NFS service"
108 startstop_nfs restart >/dev/null 2>&1 &
112 ctdb_check_counter_limit 5 quiet >/dev/null
114 echo "$ctdb_check_rpc_out"
115 echo "Trying to restart NFS service"
116 startstop_nfs restart
122 # check that lockd responds to rpc requests
123 if ctdb_check_rpc "LOCKD" 100021 1 >/dev/null ; then
124 (service_name="lockd"; ctdb_counter_init)
130 ctdb_check_counter_equal 10 || {
131 echo "Trying to restart NFS lock service"
132 startstop_nfs restart >/dev/null 2>&1 &
133 startstop_nfslock restart >/dev/null 2>&1 &
137 ctdb_check_counter_limit 15 quiet >/dev/null
139 echo "$ctdb_check_rpc_out"
140 echo "Trying to restart NFS lock service"
141 startstop_nfs restart
142 startstop_nfslock restart
147 # mount needs special handling since it is sometimes not started
149 if ctdb_check_rpc "MOUNTD" 100005 1 >/dev/null ; then
150 (service_name="nfs_mountd"; ctdb_counter_init)
153 service_name="nfs_mountd"
156 ctdb_check_counter_equal 5 || {
158 cmd="${p}${MOUNTD_PORT:+ -p }${MOUNTD_PORT}"
159 echo "Trying to restart MOUNTD [${cmd}]"
165 ctdb_check_counter_limit 10 quiet >/dev/null
167 echo "$ctdb_check_rpc_out"
169 cmd="${p}${MOUNTD_PORT:+ -p }${MOUNTD_PORT}"
170 echo "Trying to restart MOUNTD [${cmd}]"
178 # rquotad needs special handling since it is sometimes not started
180 # this is not a critical service so we dont flag the node as unhealthy
181 ctdb_check_rpc "RQUOTAD" 100011 1 || {
183 cmd="${p}${RQUOTAD_PORT:+ -p }${RQUOTAD_PORT}"
184 echo "Trying to restart RQUOTAD [${cmd}]"
189 # once every 600 seconds, update the statd state database for which
190 # clients need notifications
191 LAST_UPDATE=`stat --printf="%Y" "$service_state_dir/update-trigger"`
192 CURRENT_TIME=`date +"%s"`
193 [ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
194 touch "$service_state_dir/update-trigger"
195 $CTDB_BASE/statd-callout updatelocal &
196 $CTDB_BASE/statd-callout updateremote &
201 ctdb_standard_event_handler "$@"