Created
March 23, 2011 15:41
-
-
Save joakimk/883307 to your computer and use it in GitHub Desktop.
Some code we use to ensure that we all use the same VirtualBox and vagrant versions.
This file contains hidden or 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
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