diff --git a/manage.sh b/manage.sh index 7a1a896..4d75a76 100755 --- a/manage.sh +++ b/manage.sh @@ -335,12 +335,30 @@ run_group() { fi case "$action" in - up | start) working_result="Starting"; success_result="Started" ;; - restart) working_result="Restarting"; success_result="Restarted" ;; - stop) working_result="Stopping"; success_result="Stopped" ;; - down) working_result="Removing"; success_result="Removed" ;; - pull) working_result="Pulling"; success_result="Pulled" ;; - update) working_result="Updating"; success_result="Updated" ;; + up | start) + working_result="Starting" + success_result="Started" + ;; + restart) + working_result="Restarting" + success_result="Restarted" + ;; + stop) + working_result="Stopping" + success_result="Stopped" + ;; + down) + working_result="Removing" + success_result="Removed" + ;; + pull) + working_result="Pulling" + success_result="Pulled" + ;; + update) + working_result="Updating" + success_result="Updated" + ;; esac while :; do @@ -438,6 +456,7 @@ collect_skipped_groups() { run_all_grouped() { local action="$1" local direction="forward" + local start=0 end="${#GROUP_NAMES[@]}" step=1 local i RUN_SUCCESS=0 @@ -448,23 +467,19 @@ run_all_grouped() { if [[ "$action" == "stop" || "$action" == "down" ]]; then direction="reverse" - for ((i = ${#GROUP_NAMES[@]} - 1; i >= 0; i--)); do - if ! run_group "$i" "$action"; then - collect_skipped_groups "$i" "$direction" - print_run_summary - return 1 - fi - done - else - for ((i = 0; i < ${#GROUP_NAMES[@]}; i++)); do - if ! run_group "$i" "$action"; then - collect_skipped_groups "$i" "$direction" - print_run_summary - return 1 - fi - done + start=$((end - 1)) + end=-1 + step=-1 fi + for ((i = start; i != end; i += step)); do + if ! run_group "$i" "$action"; then + collect_skipped_groups "$i" "$direction" + print_run_summary + return 1 + fi + done + print_run_summary }