Skip to content

Instantly share code, notes, and snippets.

@colby
Created January 25, 2017 01:30
Show Gist options
  • Save colby/4909bc72a8c7280c053ce5d320cc76fd to your computer and use it in GitHub Desktop.
Save colby/4909bc72a8c7280c053ce5d320cc76fd to your computer and use it in GitHub Desktop.
#!/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