loadconfig
-service_state_dir=$(ctdb_setup_service_state_dir "system-monitoring") || exit $?
+ctdb_setup_state_dir "service" "system-monitoring"
validate_percentage ()
{
esac
_t=$(echo "$_thing" | sed -e 's@/@SLASH_@g' -e 's@ @_@g')
- _cache="${service_state_dir}/cache_${_t}"
+ # script_state_dir set by ctdb_setup_state_dir()
+ # shellcheck disable=SC2154
+ _cache="${script_state_dir}/cache_${_t}"
if validate_percentage "$_unhealthy_threshold" "$_thing" ; then
if [ "$_usage" -ge "$_unhealthy_threshold" ] ; then
echo "ERROR: ${_thing} utilization ${_usage}% >= threshold ${_unhealthy_threshold}%"
set_monitor_filsystem_usage_defaults ()
{
- _fs_defaults_cache="${service_state_dir}/cache_monitor_filsystem_usage_defaults"
+ _fs_defaults_cache="${script_state_dir}/cache_filsystem_usage_defaults"
if [ ! -r "$_fs_defaults_cache" ] ; then
# Determine filesystem for each database directory, generate
. "${CTDB_BASE}/functions"
-# service_name is used by various functions
-# shellcheck disable=SC2034
service_name="nfs"
loadconfig
-service_state_dir=$(ctdb_setup_service_state_dir) || exit $?
+
+ctdb_setup_state_dir "service" "$service_name"
######################################################################
######################################################################
-nfs_callout_init "$service_state_dir"
+# 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_BASE}/functions"
-# service_name is used by various functions
-# shellcheck disable=SC2034
-service_name=natgw
+service_name="natgw"
loadconfig
[ -n "$CTDB_NATGW_NODES" ] || exit 0
export CTDB_NATGW_NODES
-service_state_dir=$(ctdb_setup_service_state_dir) || exit $?
+ctdb_setup_state_dir "failover" "$service_name"
-natgw_cfg_new="${service_state_dir}/cfg_new"
-natgw_cfg_old="${service_state_dir}/cfg_old"
-natgw_master_old="${service_state_dir}/master_old"
+# script_state_dir set by ctdb_setup_state_dir()
+# shellcheck disable=SC2154
+natgw_cfg_new="${script_state_dir}/cfg_new"
+natgw_cfg_old="${script_state_dir}/cfg_old"
+natgw_master_old="${script_state_dir}/master_old"
ctdb_natgw_slave_only ()
{
loadconfig
-# service_name is used by various functions
-# shellcheck disable=SC2034
-service_name=per_ip_routing
+service_name="per_ip_routing"
# Do nothing if unconfigured
[ -n "$CTDB_PER_IP_ROUTING_CONF" ] || exit 0
die "error: CTDB_PER_IP_ROUTING_CONF=$CTDB_PER_IP_ROUTING_CONF file not found"
fi
-service_state_dir=$(ctdb_setup_service_state_dir) || exit $?
+ctdb_setup_state_dir "failover" "$service_name"
######################################################################
ensure_rt_tables ()
{
rt_tables="$CTDB_SYS_ETCDIR/iproute2/rt_tables"
- rt_tables_lock="${service_state_dir}/rt_tables_lock"
+ # script_state_dir set by ctdb_setup_state_dir()
+ # shellcheck disable=SC2154
+ rt_tables_lock="${script_state_dir}/rt_tables_lock"
# This file should always exist. Even if this didn't exist on the
# system, adding a route will have created it. What if we startup
. "${CTDB_BASE}/functions"
-# service_name is used by various functions
-# shellcheck disable=SC2034
service_name="multipathd"
loadconfig
[ -n "$CTDB_MONITOR_MPDEVICES" ] || exit 0
-service_state_dir=$(ctdb_setup_service_state_dir) || exit $?
+ctdb_setup_state_dir "service" "$service_name"
-multipath_fail="${service_state_dir}/fail"
+# script_state_dir set by ctdb_setup_state_dir()
+# shellcheck disable=SC2154
+multipath_fail="${script_state_dir}/fail"
multipathd_check_background()
{
;;
esac
-# service_name is used by various functions
-# shellcheck disable=SC2034
service_name="samba"
loadconfig
-service_state_dir=$(ctdb_setup_service_state_dir) || exit $?
+ctdb_setup_state_dir "service" "$service_name"
service_start ()
{
# Show the testparm output using a cached smb.conf to avoid delays due
# to registry access.
-smbconf_cache="$service_state_dir/smb.conf.cache"
+# script_state_dir set by ctdb_setup_state_dir()
+# shellcheck disable=SC2154
+smbconf_cache="$script_state_dir/smb.conf.cache"
testparm_foreground_update ()
{
. "${CTDB_BASE}/functions"
-# service_name is used by various functions
-# shellcheck disable=SC2034
service_name="nfs"
loadconfig
-service_state_dir=$(ctdb_setup_service_state_dir) || exit $?
+
+ctdb_setup_state_dir "service" "$service_name"
######################################################################
######################################################################
-nfs_callout_init "$service_state_dir"
+# script_state_dir set by ctdb_setup_state_dir()
+# shellcheck disable=SC2154
+nfs_callout_init "$script_state_dir"
is_ctdb_managed_service || exit 0
############################################################
-service_state_dir=$(ctdb_setup_service_state_dir "statd-callout") || exit $?
+ctdb_setup_state_dir "service" "nfs"
-cd "$service_state_dir" || \
- die "Failed to change directory to \"${service_state_dir}\""
+# script_state_dir set by ctdb_setup_state_dir()
+# shellcheck disable=SC2154
+d="${script_state_dir}/statd-callout"
+
+mkdir -p "$d" || die "Failed to create directory \"${d}\""
+cd "$d" || die "Failed to change directory to \"${d}\""
pnn=$(ctdb_get_pnn)