use different count to ignore case of 0 hosts
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
a512673562
commit
01a541d017
1 changed files with 13 additions and 6 deletions
|
@ -41,26 +41,33 @@ while [ $# -ge 1 ]; do
|
||||||
if [ "$parallel" ]; then
|
if [ "$parallel" ]; then
|
||||||
cdist-deploy-to "$1" | filter "$1" &
|
cdist-deploy-to "$1" | filter "$1" &
|
||||||
# Record pid and host for use later
|
# Record pid and host for use later
|
||||||
|
i=$((i+1))
|
||||||
eval pid_$i=$!
|
eval pid_$i=$!
|
||||||
eval host_$i=\$1
|
eval host_$i=\$1
|
||||||
i=$((i+1))
|
|
||||||
else
|
else
|
||||||
cdist-deploy-to "$1" | filter "$1"
|
cdist-deploy-to "$1" | filter "$1"
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# else wait after all are started
|
e=0
|
||||||
if [ "$parallel" ]; then
|
if [ "$parallel" ]; then
|
||||||
__cdist_echo info "Waiting for cdist-deploy-to jobs to finish"
|
__cdist_echo info "Waiting for cdist-deploy-to jobs to finish"
|
||||||
while [ "$i" -ge 0 ]; do
|
while [ "$i" -gt 0 ]; do
|
||||||
i=$((i-1))
|
|
||||||
eval pid=\$pid_$i
|
eval pid=\$pid_$i
|
||||||
eval host=\$host_$i
|
|
||||||
wait "$pid"
|
wait "$pid"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
__cdist_echo error "Configuration of host $host failed."
|
e=$((e+1))
|
||||||
|
eval e_host_$e=\$host_$i
|
||||||
fi
|
fi
|
||||||
|
i=$((i-1))
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Display all failed hosts after all runs are done
|
||||||
|
while [ "$e" -gt 0 ]; do
|
||||||
|
eval host=\$host_$e
|
||||||
|
__cdist_echo error "Configuration of host $host failed."
|
||||||
|
e=$((e-1))
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in a new issue