forked from ungleich-public/cdist
beautify parallel mode
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
b9ef12b48d
commit
5aa32fa42d
1 changed files with 8 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue