Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Commit

Permalink
Move vagrant_maybe_halt to vagrant functions, use for create as well …
Browse files Browse the repository at this point in the history
…as delete #194
  • Loading branch information
jb510 committed Dec 7, 2015
1 parent 9fdd495 commit 9bf43c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/create
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ create_site_maybe_restart_vagrant() {
cd "$path" || error "Could not change directory."
info "Running vagrant halt"
hook "pre_creation_pre_vagrant_halt"
vagrant halt
vagrant_maybe_halt
fi
done
}
Expand Down
8 changes: 1 addition & 7 deletions modules/delete
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ remove_site() { # @TODO refactor this if we need to
cd "$path" || error "Could not change directory."

hook "pre_site_removal_vagrant_halt" "$site" "$path"

VMTEST="$(VBoxManage list runningvms)"
if [[ $VMTEST = *VVV* ]]; then
echo "Halting Vagrant"
vagrant halt
fi

vagrant_maybe_halt
hook "post_site_removal_vagrant_halt" "$site" "$path"

# Delete the site folder
Expand Down
11 changes: 11 additions & 0 deletions modules/vagrant-commands
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ run_vagrant_up() {
hook "post_vagrant_provision"
fi
}

vagrant_maybe_halt() {
# Test if VVV is running, using `VBoxManage` because it's much faster than `vagrant status`
VMTEST="$(VBoxManage list runningvms)"
if [[ $VMTEST = *VVV* ]]; then
info "Running \`vagrant halt\`"
vagrant halt
else
info "Vagrant not running, skipping \`vagrant halt\`..."
fi
}

0 comments on commit 9bf43c7

Please # to comment.