Skip to content

Instantly share code, notes, and snippets.

@npf
Created September 10, 2014 15:09
Show Gist options
  • Save npf/26b2c25f20a1cd5a827b to your computer and use it in GitHub Desktop.
Save npf/26b2c25f20a1cd5a827b to your computer and use it in GitHub Desktop.
Wrapper around VBoxManage for vagrant to store VM disks in a different storage than VirtualBox's default.
#!/bin/bash
VBOXMANAGE=/usr/bin/VBoxManage
VBOXVMDIR="$HOME/VirtualBox VMs"
VAGRANTVMDIR="/tmp/vagrant"
LOGFILE=/tmp/vagrant/vboxmanage.$(date +%s)
echo "$0 $@" >> $LOGFILE
if [ "$1" == "import" ]; then
declare -a ARGS
while [ $# -gt 0 ]; do
ARGS=(${ARGS[@]} ${1/$VBOXVMDIR/$VAGRANTVMDIR})
shift
done
echo "===> $VBOXMANAGE ${ARGS[@]}" >> $LOGFILE
exec $VBOXMANAGE "${ARGS[@]}"
fi
exec $VBOXMANAGE "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment