. "${CTDB_BASE}/functions"
service_name="nfs"
+
loadconfig
-ctdb_setup_service_state_dir
+
+ctdb_setup_state_dir "service" "$service_name"
######################################################################
# Files must end with .check - avoids editor backups, RPM fu, ...
for _f in "$_dir"/[0-9][0-9].*.check ; do
+ [ -r "$_f" ] || continue
+
_t="${_f%.check}"
_progname="${_t##*/[0-9][0-9].}"
esac
done
- _service_name="nfs_${_progname}"
-
_ok=false
if [ -n "$service_check_cmd" ] ; then
# Using eval means variables can contain semicolon separated commands
if $_ok ; then
if [ $unhealthy_after -ne 1 -o $restart_every -ne 0 ] ; then
- ctdb_counter_init "$_service_name"
+ ctdb_counter_init "$_progname"
fi
exit 0
fi
- ctdb_counter_incr "$_service_name"
- _failcount=$(ctdb_counter_get "$_service_name")
+ ctdb_counter_incr "$_progname"
+ _failcount=$(ctdb_counter_get "$_progname")
_unhealthy=false
- if [ $unhealthy_after -gt 0 ] ; then
- if [ $_failcount -ge $unhealthy_after ] ; then
+ if [ "$unhealthy_after" -gt 0 ] ; then
+ if [ "$_failcount" -ge "$unhealthy_after" ] ; then
_unhealthy=true
echo "ERROR: $_err"
fi
fi
- if [ $restart_every -gt 0 ] ; then
- if [ $(($_failcount % $restart_every)) -eq 0 ] ; then
+ if [ "$restart_every" -gt 0 ] ; then
+ if [ $((_failcount % restart_every)) -eq 0 ] ; then
if ! $_unhealthy ; then
echo "WARNING: $_err"
fi
_localhost="${CTDB_RPCINFO_LOCALHOST:-127.0.0.1}"
esac
+ # $_version is not quoted because it is optional
+ # shellcheck disable=SC2086
if ! ctdb_check_rpc_out=$(rpcinfo -T "$_family" "$_localhost" \
"$_progname" $_version 2>&1) ; then
ctdb_check_rpc_out="$_progname failed RPC check:
######################################################################
-nfs_callout_init
-
-ctdb_start_stop_service
+# script_state_dir set by ctdb_setup_state_dir()
+# shellcheck disable=SC2154
+nfs_callout_init "$script_state_dir"
is_ctdb_managed_service || exit 0
-ctdb_service_check_reconfigure
-
case "$1" in
startup)
- nfs_callout "$@"
+ nfs_callout "$@" || exit $?
;;
shutdown)
- nfs_callout "$@"
+ nfs_callout "$@" || exit $?
;;
takeip)
- nfs_callout "$@"
+ nfs_callout "$@" || exit $?
ctdb_service_set_reconfigure
;;
releaseip)
- nfs_callout "$@"
+ nfs_callout "$@" || exit $?
ctdb_service_set_reconfigure
;;
+ipreallocated)
+ if ctdb_service_needs_reconfigure ; then
+ ctdb_service_reconfigure
+ fi
+ ;;
+
monitor)
nfs_callout "monitor-pre" || exit $?