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 ...]"
|
[ $# -ge 1 ] || __cdist_usage "[-p] <target host> [target host ...]"
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
parallel=""
|
||||||
if [ "$1" = "-p" ]; then
|
if [ "$1" = "-p" ]; then
|
||||||
parallel=yes
|
parallel=yes
|
||||||
else
|
shift
|
||||||
parallel=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while [ $# -ge 1 ]; do
|
while [ $# -ge 1 ]; do
|
||||||
if [ "$parallel" ]; then
|
# always assume we run parallel
|
||||||
cdist-deploy-to "$1" &
|
cdist-deploy-to "$1" | awk -v host=$1 '{ print "[" host "]" $0 }"' &
|
||||||
else
|
|
||||||
cdist-deploy-to "$1"
|
|
||||||
fi
|
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
# if not, wait for it _now_
|
||||||
|
[ "$parallel" ] || fg
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# else wait after all are started
|
||||||
if [ "$parallel" ]; then
|
if [ "$parallel" ]; then
|
||||||
echo "Waiting for cdist-deploy-to jobs to finish..."
|
echo "Waiting for cdist-deploy-to jobs to finish..."
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Reference in a new issue