summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2011-08-17 09:44:11 +1000
committerMartin Schwenke <martin@meltin.net>2011-08-17 10:39:35 +1000
commitf0f9271301488bbeb4bf4faed2b8c5682166f749 (patch)
treedd42dc6ec6b0e35764890b651dd7b4ae7f5aa28c
parent3e1a0528b8d887c498a7925ec0ebf97a53c9b94b (diff)
downloadsamba-f0f9271301488bbeb4bf4faed2b8c5682166f749.tar.gz
samba-f0f9271301488bbeb4bf4faed2b8c5682166f749.tar.xz
samba-f0f9271301488bbeb4bf4faed2b8c5682166f749.zip
Eventscripts: add a debug() function and call ctdb_set_current_debuglevel()
The debug function passes its arguments to echo if $CTDB_CURRENT_DEBUGLEVEL is >= 4 (i.e. DEBUG). If no args are given then use stdin - this allows the function to be used with here documents. To ensure $CTDB_CURRENT_DEBUGLEVEL is set, ctdb_set_current_debuglevel() is called near the end of the functions file. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 6143483d9f87322578c00f12081e381f425226ca)
-rwxr-xr-xctdb/config/functions19
1 files changed, 19 insertions, 0 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 26b282aa99..c6cddd462d 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -68,6 +68,20 @@ ctdb_set_current_debuglevel ()
. "$_f"
}
+debug ()
+{
+ if [ $CTDB_CURRENT_DEBUGLEVEL -ge 4 ] ; then
+ # If there are arguments then echo them. Otherwise expect to
+ # use stdin, which allows us to pass lots of debug using a
+ # here document.
+ if [ -n "$1" ] ; then
+ echo "DEBUG: $*"
+ elif ! tty -s ; then
+ sed -e 's@^@DEBUG: @'
+ fi
+ fi
+}
+
##############################################################
# determine on what type of system (init style) we are running
detect_init_style() {
@@ -1125,6 +1139,11 @@ update_tickles ()
done
}
+# We'll call this here to ensure $CTDB_CURRENT_DEBUGLEVEL is set.
+# This gives us a chance to override the debug level using a file in
+# $CTDB_BASE/rc.local.d/.
+ctdb_set_current_debuglevel
+
script_name="${0##*/}" # basename
service_name="$script_name" # default is just the script name
service_fail_limit=1