From b1f6b01e611ca5d63e1bc7451718daa83cb4f371 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 4 Sep 2022 17:40:29 -0600 Subject: [PATCH] replace while true --- functions/update_apps.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index df34f752..44e19f98 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,7 +13,7 @@ it=0 while_count=0 rm deploying 2>/dev/null rm finished 2>/dev/null -while true +while [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]] do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then ((while_count++)) @@ -38,16 +38,12 @@ do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } ((count++)) done - if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 - elif [[ $it -lt ${#array[@]} ]]; then + if [[ $it -lt ${#array[@]} && "$proc_count" -lt "$update_limit" ]]; then pre_process "${array[$it]}" & processes+=($!) ((it++)) - elif [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]; then # Wait for all processes to finish + else sleep 3 - else # All processes must be completed, break out of loop - break fi done rm deploying 2>/dev/null