From da1d3fbc0469c56b393ee0df1d33096f2cfdb1e4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 16 Apr 2011 23:51:24 +0200 Subject: [PATCH] begin new error catching code and make filter a function Signed-off-by: Nico Schottelius --- bin/cdist-mass-deploy | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/bin/cdist-mass-deploy b/bin/cdist-mass-deploy index 8a555411..294e1ca1 100755 --- a/bin/cdist-mass-deploy +++ b/bin/cdist-mass-deploy @@ -25,23 +25,38 @@ [ $# -ge 1 ] || __cdist_usage "[-p] [target host ]" set -eu +filter() +{ + awk -v host=$1 '{ print "[" host "] " $0 }' +} + parallel="" if [ "$1" = "-p" ]; then parallel=yes shift fi +i=0 while [ $# -ge 1 ]; do - # always assume we run parallel - cdist-deploy-to "$1" | awk -v host=$1 '{ print "[" host "] " $0 }' & - shift + if [ "$parallel" ]; then + cdist-deploy-to "$1" | filter + # Record pid and host for use later + eval pid_$i=$! + eval host_$i=\$1 + i=$((i+1)) + else + cdist-deploy-to "$1" | filter + fi - # if not, wait for it _now_ - [ "$parallel" ] || wait + shift done # else wait after all are started if [ "$parallel" ]; then __cdist_echo info "Waiting for cdist-deploy-to jobs to finish" + while [ $i -gt 0 ]; do + + done + wait fi