Created
May 26, 2015 12:46
-
-
Save schu/95417a659b02f7ee143f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
if [[ $# -lt 2 ]]; then | |
echo "usage: $0 <image.vdi> <name.box> [<vagrant package args>...]" >&2 | |
exit 1 | |
fi | |
readonly NAME="vdi2vagrantbox-${RANDOM}" | |
readonly IMG=$1 | |
readonly BOX=$2 | |
shift 2 | |
VBoxManage createvm --name "${NAME}" --ostype Linux26_64 --register | |
VBoxManage storagectl "${NAME}" \ | |
--name SATA --add sata --controller IntelAHCI | |
VBoxManage storageattach "${NAME}" \ | |
--storagectl SATA --port 0 --device 0 --type hdd --medium "${IMG}" | |
vagrant package --base "${NAME}" --output "${BOX}" "$@" | |
# VBoxManage unregistervm "${NAME}" --delete | |
VBoxManage unregistervm "${NAME}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment