Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Some code we use to ensure that we all use the same VirtualBox and vagrant versions.
REQUIRED_VERSION = "0.7.2"
REQUIRED_VIRTUALBOX_VERSION = "4.0.2"
#Vagrant::Config.run do |config|
# ...
#end
# Ensure a compatible Vagrant and VirtualBox versions.
INSTALL_CMD = "gem uninstall vagrant -a -x &> /dev/null &&" +
"gem install vagrant -v #{REQUIRED_VERSION} --no-ri --no-rdoc &>/dev/null"
unless Vagrant::VERSION == REQUIRED_VERSION
print "You must have vagrant #{REQUIRED_VERSION} installed. Do you want to download and install it? [Y/n]: "; STDOUT.flush
r = STDIN.gets
if r == "\n" || r == "Y\n"
puts "Installing..."
status = system(INSTALL_CMD)
if status
puts "Vagrant #{REQUIRED_VERSION} installed successfully."
else
puts "Install failed? Try manually: #{INSTALL_CMD}"
end
else
puts "Ok. Not installing."
end
exit 1
end
virtualbox_version = `VirtualBox -h|grep "VirtualBox Manager"|awk '{ print $5 }'`.chomp
if virtualbox_version != REQUIRED_VIRTUALBOX_VERSION
puts "You must have VirtualBox #{REQUIRED_VIRTUALBOX_VERSION} installed (detected: #{virtualbox_version})."
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment