-
-
Save tonejito/75f767583cc65d056343 to your computer and use it in GitHub Desktop.
Clone vagrant box locally
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 -vx | |
# Vagrant Documentation | |
# @see http://docs.vagrantup.com/v2/cli/package.html | |
# @see http://stackoverflow.com/questions/19094024/is-there-any-way-to-clone-a-vagrant-box-that-is-already-installed | |
# | |
# @fork https://gist.github.com/suplo/9758118 | |
# @fork https://gist.github.com/gecbla/9525c33af29e962555aa | |
VAGRANT=/usr/bin/vagrant | |
CLONE_NAME=clone-`date '+%s'` | |
VAGRANT_DIR=~/vagrant | |
VAGRANT_BOX_DIR=~/.vagrant.d/boxes | |
VAGRANT_BOX_FILE=$VAGRANT_BOX_DIR/$CLONE_NAME.box | |
# Export the current state into a BOX_FILE | |
$VAGRANT package --output $VAGRANT_BOX_FILE | |
# Add the BOX_FILE to the available boxes | |
$VAGRANT box add --name $CLONE_NAME --provider virtualbox $VAGRANT_BOX_FILE | |
# Chech if the box has been added | |
$VAGRANT box list | |
# Prepare clone directory for VagrantFile | |
cd $VAGRANT_DIR | |
mkdir $CLONE_NAME | |
cd $CLONE_NAME | |
# Initialize clone | |
$VAGRANT init $CLONE_NAME | |
# Get the clone up | |
$VAGRANT up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment