#!/bin/sh
VAGRANT=`which vagrant`
### User vagrant global-status to get the global ID
GLOBAL_ID='e2d06a8'
GLOBAL_DIR='/opt/vhosts/tools-deployment'
CWD=`pwd`

pushd $GLOBAL_DIR
if [[ $1 == "up" ]]
then
  $VAGRANT up $GLOBAL_ID
  ntfy -l INFO -t 'VAGRANT' send 'VM has finished booting'
elif [[ $1 == "halt" ]]
then
  $VAGRANT halt $GLOBAL_ID
  ntfy -l INFO -t 'VAGRANT' send 'VM has halted'
elif [[ $1 == "sup" ]]
then
  $VAGRANT up $GLOBAL_ID
  ntfy -l INFO -t 'VAGRANT' send 'VM has started, ssh-ing into it'
  echo 'Shelling into machine...'
  $VAGRANT ssh
else
  $VAGRANT "$@"
fi
popd