Skip to content

Instantly share code, notes, and snippets.

@gMagicScott
Forked from thom8/vagrant-box-update-all.sh
Last active August 9, 2018 15:40
Show Gist options
  • Save gMagicScott/46a179b900fc6e9b248c7c807b6c1112 to your computer and use it in GitHub Desktop.
Save gMagicScott/46a179b900fc6e9b248c7c807b6c1112 to your computer and use it in GitHub Desktop.
Update all your vagrant base boxes
#!/bin/bash
# Find all boxes which have updates
AVAILABLE_UPDATES=`vagrant box outdated --global | grep outdated | tr -d "*'" | cut -d ' ' -f 2`
if [ ! ${#AVAILABLE_UPDATES[@]} -eq 0 ]; then
for box in $AVAILABLE_UPDATES ; do
echo "Found an update for $box"
# Find all current versions
VERSIONS=`vagrant box list | grep $box | cut -d ',' -f 2 | tr -d ' )'`
# Add latest version
vagrant box add --clean --provider virtualbox $box
BOX_UPDATED="TRUE"
# Remove all old versions
for version in $VERSIONS ; do
vagrant box remove $box -f --box-version=$version
done
done
echo "All boxes are now up to date!"
else
echo "All boxes are already up to date!"
fi
vagrant box outdated --global
@gMagicScott
Copy link
Author

curl -LSs https://git.io/vVsI0 | bash

@gMagicScott
Copy link
Author

curl -LSs https://gist.githubusercontent.com/gMagicScott/46a179b900fc6e9b248c7c807b6c1112/raw/vagrant-box-update-all.sh | bash

@lurch
Copy link

lurch commented Nov 29, 2017

This is great, thank you!

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