beautify parallel mode

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-04-06 14:16:33 +02:00
parent b9ef12b48d
commit 5aa32fa42d

View file

@ -25,21 +25,22 @@
[ $# -ge 1 ] || __cdist_usage "[-p] <target host> [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