2007-06-01 18:10:22 +04:00
#!/bin/sh
# script to manage nfs in a clustered environment
2013-01-03 08:26:12 +04:00
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
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"
2011-08-11 03:39:25 +04:00
service_start ()
{
startstop_nfs stop
startstop_nfs start
set_proc "sys/net/ipv4/tcp_tw_recycle" 1
}
service_stop ()
{
startstop_nfs stop
}
2011-08-11 07:55:02 +04:00
service_reconfigure ()
{
2011-05-23 10:00:05 +04:00
# if the ips have been reallocated, we must restart the lockmanager
# across all nodes and ping all statd listeners
[ -x $CTDB_BASE/statd-callout ] && {
$CTDB_BASE/statd-callout notify &
} >/dev/null 2>&1
2011-08-11 07:55:02 +04:00
}
2008-02-11 01:35:37 +03:00
2013-06-13 04:17:20 +04:00
nfs_check_thread_count ()
{
[ "$CTDB_MONITOR_NFS_THREAD_COUNT" = "yes" ] || return 0
# If $RPCNFSDCOUNT/$USE_KERNEL_NFSD_NUMBER isn't set then we could
# guess the default from the initscript. However, let's just
# assume that those using the default don't care about the number
# of threads and that they have switched on this feature in error.
_configured_threads="${RPCNFSDCOUNT:-${USE_KERNEL_NFSD_NUMBER}}"
[ -n "$_configured_threads" ] || return 0
# nfsd should be running the configured number of threads. If
# there are a different number of threads then tell nfsd the
# correct number.
_running_threads=$(get_proc "fs/nfsd/threads")
# Intentionally not arithmetic comparison - avoids extra errors
# when get_proc() fails...
if [ "$_running_threads" != "$_configured_threads" ] ; then
echo "Attempting to correct number of nfsd threads from ${_running_threads} to ${_configured_threads}"
set_proc "fs/nfsd/threads" "$_configured_threads"
fi
}
2009-11-19 07:00:17 +03:00
loadconfig
2013-10-15 04:29:23 +04:00
[ "${CTDB_NFS_SERVER_MODE:-${NFS_SERVER_MODE}}" != "ganesha" ] || exit 0
2010-12-04 02:26:22 +03:00
2010-12-16 00:57:46 +03:00
ctdb_setup_service_state_dir
2009-11-19 07:00:17 +03:00
ctdb_start_stop_service
2008-02-11 01:35:37 +03:00
2010-11-18 05:23:40 +03:00
is_ctdb_managed_service || exit 0
2010-12-16 01:45:28 +03:00
ctdb_service_check_reconfigure
2009-12-01 09:43:47 +03:00
case "$1" in
2010-08-30 12:13:28 +04:00
init)
# read statd from persistent database
;;
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
2007-06-01 18:10:22 +04:00
;;
releaseip)
2009-11-19 07:00:17 +03:00
ctdb_service_set_reconfigure
2007-06-01 18:10:22 +04:00
;;
2007-06-06 06:08:42 +04:00
monitor)
2010-12-17 08:25:04 +03:00
# Check that directories for shares actually exist.
2011-08-11 01:13:28 +04:00
[ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
2011-04-13 06:37:42 +04:00
exportfs -v | grep '^/' |
sed -r -e 's@[[:space:]]+[^[:space:]()]+\([^[:space:]()]+\)$@@' |
2011-08-17 11:42:07 +04:00
sort -u |
2011-04-13 06:37:42 +04:00
ctdb_check_directories
2011-08-11 01:13:28 +04:00
} || exit $?
2010-08-26 08:59:59 +04:00
update_tickles 2049
2015-02-13 12:55:43 +03:00
nfs_update_lock_info
2010-08-26 08:59:59 +04:00
2013-04-23 06:17:31 +04:00
nfs_check_rpc_services
2010-08-30 12:13:28 +04:00
2013-06-13 04:17:20 +04:00
nfs_check_thread_count
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