QR Code Business Card

Vagrant shell script

Working with several Vagrant boxes in parallel can be tricky. So today I wrote a small shell script to help me here. It will

  • start the VM (if not already running),
  • Login into the VM via SSH,
  • suspend the VM after exiting the VM (if you want)

Shell script:
#/bin/bash
if [ -f ./Vagrantfile ]
then
if vagrant status | grep -q "running ("
then
echo Box is already running
else
echo Starting box ...
vagrant up
fi
echo Login in ...
vagrant ssh
read -n1 -p "Suspend box ? [y,N]" doit
case $doit in
y|Y) vagrant suspend ;;
n|N) echo OK ;;
*) echo OK ;;
esac
else
echo No Vagrantfile found!
fi


Leave a Reply