Created
January 25, 2017 01:30
-
-
Save colby/4909bc72a8c7280c053ce5d320cc76fd to your computer and use it in GitHub Desktop.
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 | vagrant global-status | $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