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="startstop_nfs restart"
22 [ "$NFS_SERVER_MODE" != "GANESHA" ] || exit 0
24 ctdb_setup_service_state_dir
26 ctdb_start_stop_service
28 is_ctdb_managed_service || exit 0
30 ctdb_service_check_reconfigure
34 # read statd from persistent database
45 ctdb_service_set_reconfigure
49 ctdb_service_set_reconfigure
53 # and that its directories are available
54 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
55 exportfs | grep -v '^#' | grep '^/' |
56 sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
57 ctdb_check_directories
62 # check that statd responds to rpc requests
63 # if statd is not running we try to restart it
64 # we only do this IF we have a rpc.statd command.
65 # For platforms where rpc.statd does not exist, we skip
66 # the check completely
68 which $p >/dev/null 2>/dev/null && {
69 if ctdb_check_rpc "STATD" 100024 1 >/dev/null ; then
70 (service_name="nfs_statd"; ctdb_counter_init)
73 cmd="${cmd}${STATD_HOSTNAME:+ -n }${STATD_HOSTNAME}"
74 cmd="${cmd}${STATD_PORT:+ -p }${STATD_PORT}"
75 cmd="${cmd}${STATD_OUTGOING_PORT:+ -o }${STATD_OUTGOING_PORT}"
77 service_name="nfs_statd"
79 ctdb_check_counter_limit 10 quiet >/dev/null
81 echo "$ctdb_check_rpc_out"
82 echo "Trying to restart STATD [$cmd]"
88 # check that NFS responds to rpc requests
89 [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
90 if ctdb_check_rpc "NFS" 100003 3 >/dev/null ; then
91 (service_name="nfs_knfsd"; ctdb_counter_init)
94 service_name="nfs_knfsd"
97 ctdb_check_counter_equal 2 || {
98 echo "Trying to restart NFS service"
99 startstop_nfs restart >/dev/null 2>&1 &
103 ctdb_check_counter_limit 5 quiet >/dev/null
105 echo "$ctdb_check_rpc_out"
106 echo "Trying to restart NFS service"
107 startstop_nfs restart
113 # check that lockd responds to rpc requests
114 if ctdb_check_rpc "LOCKD" 100021 1 >/dev/null ; then
115 (service_name="lockd"; ctdb_counter_init)
121 ctdb_check_counter_equal 10 || {
122 echo "Trying to restart NFS lock service"
123 startstop_nfs restart >/dev/null 2>&1 &
124 startstop_nfslock restart >/dev/null 2>&1 &
128 ctdb_check_counter_limit 15 quiet >/dev/null
130 echo "$ctdb_check_rpc_out"
131 echo "Trying to restart NFS lock service"
132 startstop_nfs restart
133 startstop_nfslock restart
138 # mount needs special handling since it is sometimes not started
140 if ctdb_check_rpc "MOUNTD" 100005 1 >/dev/null ; then
141 (service_name="nfs_mountd"; ctdb_counter_init)
144 service_name="nfs_mountd"
147 ctdb_check_counter_equal 5 || {
149 cmd="${p}${MOUNTD_PORT:+ -p }${MOUNTD_PORT}"
150 echo "Trying to restart MOUNTD [${cmd}]"
156 ctdb_check_counter_limit 10 quiet >/dev/null
158 echo "$ctdb_check_rpc_out"
160 cmd="${p}${MOUNTD_PORT:+ -p }${MOUNTD_PORT}"
161 echo "Trying to restart MOUNTD [${cmd}]"
169 # rquotad needs special handling since it is sometimes not started
171 # this is not a critical service so we dont flag the node as unhealthy
172 ctdb_check_rpc "RQUOTAD" 100011 1 || {
174 cmd="${p}${RQUOTAD_PORT:+ -p }${RQUOTAD_PORT}"
175 echo "Trying to restart RQUOTAD [${cmd}]"
180 # once every 600 seconds, update the statd state database for which
181 # clients need notifications
182 LAST_UPDATE=`stat --printf="%Y" "$service_state_dir/update-trigger"`
183 CURRENT_TIME=`date +"%s"`
184 [ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
185 touch "$service_state_dir/update-trigger"
186 $CTDB_BASE/statd-callout updatelocal &
187 $CTDB_BASE/statd-callout updateremote &
192 # if the ips have been reallocated, we must restart the lockmanager
193 # across all nodes and ping all statd listeners
194 [ -x $CTDB_BASE/statd-callout ] && {
195 $CTDB_BASE/statd-callout notify &
199 ctdb_standard_event_handler "$@"