Skip to content

Instantly share code, notes, and snippets.

@xrd
Created July 22, 2013 16:56
Show Gist options
  • Select an option

  • Save xrd/6055536 to your computer and use it in GitHub Desktop.

Select an option

Save xrd/6055536 to your computer and use it in GitHub Desktop.
Upgrade vagrant boxes directory to 1.2
#!/bin/bash
LOG_RESTORE_SCRIPT=vagrant-update.`date +%Y-%m-%d`-$$.log.sh
cd ~/.vagrant.d/boxes
echo "#/bin/bash" >> $LOG_RESTORE_SCRIPT
echo "cd ~/.vagrant.d/boxes" >> $LOG_RESTORE_SCRIPT
for x in `ls | grep -v '\.log\.sh'`; do
if [ ! -d "$x/virtualbox" ]; then
echo "# Processing: " $x | tee -a $LOG_RESTORE_SCRIPT
mkdir -p $x/virtualbox
for y in `ls $x`; do
mv $x/$y $x/virtualbox/$y
echo "mv $x/virtualbox/$y $x/$y" >> $LOG_RESTORE_SCRIPT
done
# Put the metadata.json file in there
echo '{"provider":"virtualbox"}' > $x/virtualbox/metadata.json
echo "rm $x/virtualbox/metadata.json" >> $LOG_RESTORE_SCRIPT
else
echo "# Skipping already converted updated directory [$x]"
fi
done
@xrd
Copy link
Copy Markdown
Author

xrd commented Jul 22, 2013

This script upgrades your .vagrant.d/boxes directory to the 1.2 vagrant format, and writes a log file of the changes, a file which also can be run to restore the changes if you want to revert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment