2007-06-01 18:10:22 +04:00
#!/bin/sh
# script to manage nfs in a clustered environment
2009-11-19 07:00:17 +03:00
start_nfs() {
/bin/mkdir -p $CTDB_BASE/state/nfs
/bin/mkdir -p $CTDB_BASE/state/statd/ip
/bin/mkdir -p $STATD_SHARED_DIRECTORY
startstop_nfs stop
startstop_nfs start
}
2007-06-01 18:10:22 +04:00
2009-11-19 07:00:17 +03:00
reconfigure_nfs() {
# always restart the lockmanager so that we start with a clusterwide
# graceperiod when ip addresses has changed
[ -x $CTDB_BASE/statd-callout ] && {
$CTDB_BASE/statd-callout notify &
} >/dev/null 2>&1
2007-06-02 10:44:15 +04:00
2009-11-19 07:00:17 +03:00
}
2007-06-01 18:10:22 +04:00
2009-11-19 07:00:17 +03:00
. $CTDB_BASE/functions
2007-06-06 06:08:42 +04:00
2009-11-19 07:00:17 +03:00
service_name="nfs"
service_start="start_nfs"
service_stop="startstop_nfs stop"
service_reconfigure="reconfigure_nfs"
2008-02-11 01:35:37 +03:00
2009-11-19 07:00:17 +03:00
loadconfig
[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
ctdb_start_stop_service
2008-02-11 01:35:37 +03:00
2009-12-01 09:43:47 +03:00
case "$1" in
2007-06-01 18:10:22 +04:00
startup)
2009-11-19 07:00:17 +03:00
ctdb_service_start
2007-06-02 10:44:15 +04:00
;;
shutdown)
2009-11-19 07:00:17 +03:00
ctdb_service_stop
2007-07-06 04:54:42 +04:00
;;
takeip)
2009-11-19 07:00:17 +03:00
ctdb_service_set_reconfigure
2009-12-01 09:43:47 +03:00
touch $CTDB_BASE/state/statd/ip/$3
2007-06-01 18:10:22 +04:00
;;
releaseip)
2009-11-19 07:00:17 +03:00
ctdb_service_set_reconfigure
2009-12-01 09:43:47 +03:00
/bin/rm -f $CTDB_BASE/state/statd/ip/$3
2007-09-10 01:20:44 +04:00
;;
recovered)
2009-11-19 07:00:17 +03:00
# if we have taken or released any ips we must
# restart the lock manager so that we enter a clusterwide grace period
if ctdb_service_needs_reconfigure ; then
ctdb_service_reconfigure
fi
2007-06-01 18:10:22 +04:00
;;
2007-06-06 06:08:42 +04:00
monitor)
2009-11-19 07:00:17 +03:00
if ctdb_service_needs_reconfigure ; then
ctdb_service_reconfigure
exit 0
fi
2008-01-21 04:46:11 +03:00
# check that statd responds to rpc requests
2009-09-15 13:33:53 +04:00
# if statd is not running we try to restart it
rpcinfo -u localhost 100024 1 > /dev/null || {
RPCSTATDOPTS=""
[ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
[ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
[ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
rpc.statd $RPCSTATDOPTS
echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
}
2008-01-21 04:46:11 +03:00
2008-07-08 03:58:10 +04:00
2007-06-06 06:08:42 +04:00
# check that NFS responds to rpc requests
2010-02-11 03:09:39 +03:00
[ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
2010-08-19 01:18:22 +04:00
(ctdb_check_rpc "NFS" 100003 3)
[ $? = "0" ] || {
echo "Trying to restart NFS service"
startstop_nfs restart
exit 1
}
2010-02-11 03:09:39 +03:00
}
2007-06-06 06:08:42 +04:00
# and that its directories are available
2009-03-03 23:21:55 +03:00
[ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
2009-11-20 08:45:36 +03:00
exportfs | grep -v '^#' | grep '^/' |
2010-02-23 13:00:23 +03:00
sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
2009-11-20 08:45:36 +03:00
ctdb_check_directories
} || exit $?
2007-07-06 04:54:42 +04:00
# check that lockd responds to rpc requests
ctdb_check_rpc "lockd" 100021 1
2009-11-20 08:45:36 +03:00
echo "$STATD_SHARED_DIRECTORY" | ctdb_check_directories "statd" || \
exit $?
2007-10-23 06:35:43 +04:00
# mount needs special handling since it is sometimes not started
# correctly on RHEL5
rpcinfo -u localhost 100005 1 > /dev/null || {
2008-01-16 14:06:44 +03:00
echo "ERROR: MOUNTD is not running. Trying to restart it."
2007-10-23 06:35:43 +04:00
RPCMOUNTDOPTS=""
[ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
killall -q -9 rpc.mountd
rpc.mountd $RPCMOUNTDOPTS &
exit 1
}
2010-02-12 05:19:57 +03:00
# rquotad needs special handling since it is sometimes not started
# correctly on RHEL5
# this is not a critical service so we dont flag the node as unhealthy
rpcinfo -u localhost 100011 1 > /dev/null || {
echo "ERROR: RQUOTAD is not running. Trying to restart it."
RPCRQUOTADOPTS=""
[ -n "$RQUOTAD_PORT" ] && RPCRQUOTADOPTS="$RPCRQUOTADOPTS -p $RQUOTAD_PORT"
killall -q -9 rpc.rquotad
rpc.rquotad $RPCRQUOTADOPTS &
}
2008-07-10 02:05:34 +04:00
;;
2007-06-06 06:08:42 +04:00
2009-12-01 09:43:47 +03:00
*)
ctdb_standard_event_handler "$@"
2009-11-19 07:00:17 +03:00
;;
2007-06-01 18:10:22 +04:00
esac
exit 0