diff --git a/ansible/roles/bhyve/files/bhyverc.bash b/ansible/roles/bhyve/files/bhyverc.bash index 190306a..0253d37 100644 --- a/ansible/roles/bhyve/files/bhyverc.bash +++ b/ansible/roles/bhyve/files/bhyverc.bash @@ -85,15 +85,18 @@ function main { function start { local num_vms="$#" - - if [ "$num_vms" -gt 0 ]; then - for name in "$@"; do - log "Starting VM $name." - start_one "$name" - done - else + if [ "$num_vms" -eq 0 ]; then log "No VMs specified." + return 0 fi + + while [ "$#" -gt 0 ]; do + local name="$1" + shift 1 + log "Starting VM $name." + start_one "$name" + [ "$#" -eq 0 ] || sleep 5 + done } function start_one { @@ -115,15 +118,18 @@ export -f launch_pidfile function stop { local num_vms="$#" - - if [ "$num_vms" -gt 0 ]; then - for name in "$@"; do - log "Stopping VM $name." - stop_one "$name" - done - else + if [ "$num_vms" -eq 0 ]; then log "No VMs specified." + return 0 fi + + while [ "$#" -gt 0 ]; do + local name="$1" + shift 1 + log "Stopping VM $name." + stop_one "$name" + [ "$#" -eq 0 ] || sleep 5 + done } function stop_one {