summaryrefslogtreecommitdiff
path: root/ctdb/tools/onnode
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-07-14 09:19:22 +1000
committerAndrew Tridgell <tridge@samba.org>2008-07-14 09:19:22 +1000
commit3fa8aaa4e2f4931ac968bff2d85b98908c323d24 (patch)
treeec7fba828c5c564fb68bd03647dd537766c79291 /ctdb/tools/onnode
parent3bb727aaafddbe46abcbea4a6aeb7b4ae831f0f4 (diff)
downloadsamba-3fa8aaa4e2f4931ac968bff2d85b98908c323d24.tar.gz
fixed up exit status for onnode
(This used to be ctdb commit c26afe26cc5c1f9cd9eef74166b5fc39dde591d3)
Diffstat (limited to 'ctdb/tools/onnode')
-rwxr-xr-xctdb/tools/onnode18
1 files changed, 15 insertions, 3 deletions
diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode
index 1e7e24690fa..6d8ed17f042 100755
--- a/ctdb/tools/onnode
+++ b/ctdb/tools/onnode
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Run commands on CTDB nodes.
@@ -171,9 +171,12 @@ trap 'kill -TERM $pids 2>/dev/null' INT TERM
# There's a small race here where the kill can fail if no processes
# have been added to $pids and the script is interrupted. However,
# the part of the window where it matter is very small.
+retcode=0
for n in $nodes ; do
if $parallel ; then
if $verbose ; then
+ # pipefail is a bashism - is there some way to do this with plain sh?
+ set -o pipefail 2>/dev/null
($SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command" 2>&1 | sed -e "s@^@[$n] @" )&
else
$SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command" &
@@ -184,8 +187,17 @@ for n in $nodes ; do
echo >&2 ; echo ">> NODE: $n <<" >&2
fi
- $SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command"
+ $SSH $ssh_opts $EXTRA_SSH_OPTS $n "$command"
+ [ $? = 0 ] || retcode=$?
fi
done
-$parallel && wait
+$parallel && {
+ for p in $pids; do
+ wait $p
+ [ $? = 0 ] || retcode=$?
+ done
+}
+
+exit $retcode
+