mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
Eventscripts - new function ctdb_set_current_debuglevel()
This function ensures that CTDB_CURRENT_DEBUGLEVEL is set. It works like this: 1. If it is already set then do nothing, since it might have been set some other way. The recommended "other way" would be to add a file in rc.local.d/. 2. If it is not set then set it by sourcing /var/ctdb/eventscript_debuglevel. 3. If this file does not exist then create it using output from "ctdb getdebug". If the optional 1st argument is set to "create" then don't source an existing file but create a new one instead - this is useful for creating the file just once in each event run in, say, 00.ctdb. If there's a problem getting the debug level from ctdb then it is silently set to 0 - no use spamming logs if our debug code is broken... Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 93910921c8a25f2b029733cd938069ff7c7bdab7)
This commit is contained in:
@ -37,6 +37,37 @@ loadconfig () {
|
||||
_loadconfig "$@"
|
||||
}
|
||||
|
||||
##############################################################
|
||||
# make sure CTDB_CURRENT_DEBUGLEVEL is set to the desired debug level
|
||||
# (integer)
|
||||
#
|
||||
# If it is already set then do nothing, since it might have been set
|
||||
# via a file in rc.local.d/. If it is not set then set it by sourcing
|
||||
# /var/ctdb/eventscript_debuglevel. If this file does not exist then
|
||||
# create it using output from "ctdb getdebug". If the option 1st arg
|
||||
# is "create" then don't source an existing file but create a new one
|
||||
# instead - this is useful for creating the file just once in each
|
||||
# event run in 00.ctdb. If there's a problem getting the debug level
|
||||
# from ctdb then it is silently set to 0 - no use spamming logs if our
|
||||
# debug code is broken...
|
||||
ctdb_set_current_debuglevel ()
|
||||
{
|
||||
[ -z "$CTDB_CURRENT_DEBUGLEVEL" ] || return 0
|
||||
|
||||
_f="$CTDB_VARDIR/eventscript_debuglevel"
|
||||
|
||||
if [ "$1" = "create" -o ! -r "$_f" ] ; then
|
||||
_t=$(ctdb getdebug -Y 2>/dev/null)
|
||||
# get last field of output
|
||||
_t="${_t%:}"
|
||||
_t="${_t##*:}"
|
||||
# Defaults to 0
|
||||
echo "export CTDB_CURRENT_DEBUGLEVEL=\"${_t:-0}\"" >"$_f"
|
||||
fi
|
||||
|
||||
. "$_f"
|
||||
}
|
||||
|
||||
##############################################################
|
||||
# determine on what type of system (init style) we are running
|
||||
detect_init_style() {
|
||||
|
Reference in New Issue
Block a user