Skip to content

Instantly share code, notes, and snippets.

@mohclips
Created February 2, 2017 07:29
Show Gist options
  • Save mohclips/28dfc70dea4753c7238cf8c0b77290ce to your computer and use it in GitHub Desktop.
Save mohclips/28dfc70dea4753c7238cf8c0b77290ce to your computer and use it in GitHub Desktop.
rebuilds a named vagrant vm
#!/bin/bash
V=$1
containers=$(cat ~/.vagrant.d/data/machine-index/index | jq '.machines[] | {name} | to_entries[] | .value')
if [ $(echo $containers | grep -c \"$V\") -ne 1 ] ; then
echo "Can't find $V in container list"
echo $containers
exit 2
fi
echo "**Rebuilding... $V"
echo "*Halt"
vagrant halt -f $V
echo "*Destroy"
vagrant destroy -f $V
echo "*Up"
vagrant up $V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment