Created
November 17, 2016 05:49
-
-
Save colby/b05ac014968e6dbf4b20bd672dbf4d2f to your computer and use it in GitHub Desktop.
Put all of your Vagrant VMs to sleep.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
vagrant=$(which vagrant) | |
awk=$(which awk) | |
printf "Gathering a list of machines. " | |
machines=$(vagrant global-status --prune 2>/dev/null | $awk '/running/ {print $5}') | |
if [ ! -z "${machines[@]}" ] | |
then | |
printf "Putting them to bed. " | |
for m in ${machines[@]} | |
do | |
test -d "$m" && cd "$m" && $vagrant halt > /dev/null 2>&1; printf 'z' | |
done | |
printf "\n" | |
else | |
printf "They're all asleep!\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment