Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Automatically check and abort if VirtualBox version not compatible #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ Vagrant.configure('2') do |config|
# We have tried using NFS but it's super slow compared to synced_folder
config.vm.synced_folder DIR, '/data/wordpress/', owner: 'vagrant', group: 'vagrant', mount_options: ['dmode=775', 'fmode=775']


# For Self-signed ssl-certificate
ssl_cert_path = File.join(DIR,'.vagrant','ssl')
unless File.exists? File.join(ssl_cert_path,'development.crt')
Expand All @@ -145,6 +144,7 @@ Vagrant.configure('2') do |config|
end

config.vm.provider 'virtualbox' do |vb|

# Give VM access to all cpu cores on the host
cpus = case RbConfig::CONFIG['host_os']
when /darwin/ then `sysctl -n hw.physicalcpu`.to_i
Expand All @@ -162,6 +162,10 @@ Vagrant.configure('2') do |config|
vb.customize ['modifyvm', :id, '--uartmode1', 'disconnected']
end

virtualbox_version_check
puts "end"
exit 1

end

##
Expand Down Expand Up @@ -483,6 +487,28 @@ def vagrant_running?
system("vagrant status --machine-readable | grep state,running --quiet")
end

def virtualbox_version_check
min_ver = "5.2"
max_ver = "6.1"

vboxmanage = Vagrant::Util::Which.which("VBoxManage") || Vagrant::Util::Which.which("VBoxManage.exe")
if vboxmanage != nil
s = Vagrant::Util::Subprocess.execute(vboxmanage, '--version')
ver = s.stdout.strip![0..2]
puts "Found VirtualBox version #{ver}"
else
STDERR.puts "VirtualBox not installed, aborting.."
exit 1
end

if ver <= min_ver
STDERR.puts "VirtualBox version #{ver} is too low. Requires at least #{min_ver}."
elsif ver > max_ver
STDERR.puts "VirtualBox version #{ver} is too high. Please downgrade to #{max_ver}."
end
exit 1
end

##
# On OS X we can use a few more features like zeroconf (discovery of .local addresses in local network)
##
Expand Down