eventscripts: Clean up ctdb_check_command()
authorMartin Schwenke <martin@meltin.net>
Mon, 29 Apr 2013 17:54:17 +0000 (03:54 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Mon, 6 May 2013 05:45:10 +0000 (15:45 +1000)
* Command is now multiple arguments, preserving quoting
* $service_name no longer printed, no longer an argument
* Debug output from failed command

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/events.d/49.winbind
config/functions
tests/eventscripts/49.winbind.monitor.102.sh

index d0a154d0bc069096cfca927c40888a40a0ce3002..ef4eb3fbeb422b73aae027b68f77714d1ce8d0e7 100755 (executable)
@@ -54,7 +54,7 @@ case "$1" in
        ;;
 
      monitor)
-       ctdb_check_command "winbind" "wbinfo -p"
+       ctdb_check_command wbinfo -p
        ;;
 
      takeip|releaseip)
index 76f94a4de432e3354273fe834441094f7d36d15b..c9dd4d599e3234afdc655e8aa44eebb9fdf3c4e3 100755 (executable)
@@ -570,16 +570,15 @@ ctdb_check_unix_socket() {
 
 ######################################################
 # check a command returns zero status
-# usage: ctdb_check_command SERVICE_NAME <command>
+# usage: ctdb_check_command <command>
 ######################################################
-ctdb_check_command() {
-  service_name="$1"
-  wait_cmd="$2"
-  [ -z "$wait_cmd" ] && return;
-  $wait_cmd > /dev/null 2>&1 || {
-      echo "ERROR: $service_name - $wait_cmd returned error"
-      exit 1
-  }
+ctdb_check_command ()
+{
+    _out=$("$@" 2>&1) || {
+       echo "ERROR: $* returned error"
+       echo "$_out" | debug
+       exit 1
+    }
 }
 
 ################################################
index 77e2a32d98798e8b11c2085d5c2958c95384e153..e4a4cacb3f25890d26003dfeed4e149557e5a4c9 100755 (executable)
@@ -7,6 +7,6 @@ define_test "winbind down"
 setup_winbind
 wbinfo_down
 
-required_result 1 "ERROR: winbind - wbinfo -p returned error"
+required_result 1 "ERROR: wbinfo -p returned error"
 
 simple_test