From 5aa32fa42d042e82dc9a69f26ac8fba18ba27f2b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 6 Apr 2011 14:16:33 +0200 Subject: [PATCH] beautify parallel mode Signed-off-by: Nico Schottelius --- bin/cdist-mass-deploy | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/cdist-mass-deploy b/bin/cdist-mass-deploy index f5790c03..f3e526cc 100755 --- a/bin/cdist-mass-deploy +++ b/bin/cdist-mass-deploy @@ -25,21 +25,22 @@ [ $# -ge 1 ] || __cdist_usage "[-p] [target host ...]" set -eu +parallel="" if [ "$1" = "-p" ]; then parallel=yes -else - parallel="" + shift fi while [ $# -ge 1 ]; do - if [ "$parallel" ]; then - cdist-deploy-to "$1" & - else - cdist-deploy-to "$1" - fi + # always assume we run parallel + cdist-deploy-to "$1" | awk -v host=$1 '{ print "[" host "]" $0 }"' & shift + + # if not, wait for it _now_ + [ "$parallel" ] || fg done +# else wait after all are started if [ "$parallel" ]; then echo "Waiting for cdist-deploy-to jobs to finish..." wait