diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f013b78c..29770ad2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,32 +9,22 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl update_limit=2 current_updates=0 - -while true +it=0 +while [[ $it -lt ${#array[@]} ]] do - if [[ current_updates -ge "$update_limit" ]]; then - sleep 5 + jobs=$(jobs -p | wc -l) + if [[ "$jobs" -ge "$update_limit" ]]; then + sleep 3 else - for i in "${array[@]}" - do - { update_apps "$i"; (( current_updates-- )) ;} & (( current_updates++ )) - processes+=($!) - done + update_apps "${#array[$it]}" & + processes+=($!) + ((it++)) fi done - - - - - - - - - for proc in "${processes[@]}" do wait "$proc"