hosts/windows: install VirtualBox
This commit is contained in:
parent
dad5962ebb
commit
abb1030f10
|
@ -0,0 +1,51 @@
|
||||||
|
require "pathname"
|
||||||
|
require "tempfile"
|
||||||
|
|
||||||
|
require "vagrant/util/downloader"
|
||||||
|
require "vagrant/util/subprocess"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module HostWindows
|
||||||
|
module Cap
|
||||||
|
class ProviderInstallVirtualBox
|
||||||
|
# The URL to download VirtualBox is hardcoded so we can have a
|
||||||
|
# known-good version to download.
|
||||||
|
URL = "http://download.virtualbox.org/virtualbox/5.0.8/VirtualBox-5.0.8-103449-Win.exe".freeze
|
||||||
|
VERSION = "5.0.8".freeze
|
||||||
|
|
||||||
|
def self.provider_install_virtualbox(env)
|
||||||
|
tf = Tempfile.new("vagrant")
|
||||||
|
tf.close
|
||||||
|
|
||||||
|
# Prefixed UI for prettiness
|
||||||
|
ui = Vagrant::UI::Prefixed.new(env.ui, "")
|
||||||
|
|
||||||
|
# Start by downloading the file using the standard mechanism
|
||||||
|
ui.output(I18n.t(
|
||||||
|
"vagrant.hosts.windows.virtualbox_install_download",
|
||||||
|
version: VERSION))
|
||||||
|
ui.detail(I18n.t(
|
||||||
|
"vagrant.hosts.windows.virtualbox_install_detail"))
|
||||||
|
dl = Vagrant::Util::Downloader.new(URL, tf.path, ui: ui)
|
||||||
|
dl.download!
|
||||||
|
|
||||||
|
# Launch it
|
||||||
|
ui.output(I18n.t(
|
||||||
|
"vagrant.hosts.windows.virtualbox_install_install"))
|
||||||
|
ui.detail(I18n.t(
|
||||||
|
"vagrant.hosts.windows.virtualbox_install_install_detail"))
|
||||||
|
script = File.expand_path("../../scripts/install_virtualbox.ps1", __FILE__)
|
||||||
|
result = Vagrant::Util::Powershell.execute(script, tf.path)
|
||||||
|
if result.exit_code != 0
|
||||||
|
raise Vagrant::Errors::ProviderInstallFailed,
|
||||||
|
provider: "virtualbox",
|
||||||
|
stdout: result.stdout,
|
||||||
|
stderr: result.stderr
|
||||||
|
end
|
||||||
|
|
||||||
|
ui.success(I18n.t("vagrant.hosts.windows.virtualbox_install_success"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,6 +11,11 @@ module VagrantPlugins
|
||||||
Host
|
Host
|
||||||
end
|
end
|
||||||
|
|
||||||
|
host_capability("windows", "provider_install_virtualbox") do
|
||||||
|
require_relative "cap/provider_install_virtualbox"
|
||||||
|
Cap::ProviderInstallVirtualBox
|
||||||
|
end
|
||||||
|
|
||||||
host_capability("windows", "nfs_installed") do
|
host_capability("windows", "nfs_installed") do
|
||||||
require_relative "cap/nfs"
|
require_relative "cap/nfs"
|
||||||
Cap::NFS
|
Cap::NFS
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory=$True)]
|
||||||
|
[string]$path
|
||||||
|
)
|
||||||
|
|
||||||
|
# Stop on first error
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
# Make the path complete
|
||||||
|
$path = Resolve-Path $path
|
||||||
|
|
||||||
|
# Determine if this is a 64-bit or 32-bit CPU
|
||||||
|
$architecture="x86"
|
||||||
|
if ((Get-WmiObject -Class Win32_OperatingSystem).OSArchitecture -eq "64-bit") {
|
||||||
|
$architecture = "amd64"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extract the contents of the installer
|
||||||
|
Start-Process -FilePath $path `
|
||||||
|
-ArgumentList ('--extract','--silent','--path','.') `
|
||||||
|
-Wait `
|
||||||
|
-NoNewWindow
|
||||||
|
|
||||||
|
# Find the installer
|
||||||
|
$matches = Get-ChildItem | Where-Object { $_.Name -match "VirtualBox-.*_$($architecture).msi" }
|
||||||
|
if ($matches.Count -ne 1) {
|
||||||
|
Write-Host "Multiple matches for VirtualBox MSI found: $($matches.Count)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
$installerPath = Resolve-Path $matches[0]
|
||||||
|
|
||||||
|
# Run the installer
|
||||||
|
Start-Process -FilePath "$($env:systemroot)\System32\msiexec.exe" `
|
||||||
|
-ArgumentList "/i `"$installerPath`" /qn /norestart /l*v `"$($pwd)\install.log`"" `
|
||||||
|
-Verb RunAs `
|
||||||
|
-Wait `
|
||||||
|
-WorkingDirectory "$pwd"
|
|
@ -1899,6 +1899,22 @@ en:
|
||||||
arch:
|
arch:
|
||||||
nfs_export:
|
nfs_export:
|
||||||
prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..."
|
prepare: "Preparing to edit /etc/exports. Administrator privileges will be required..."
|
||||||
|
windows:
|
||||||
|
virtualbox_install_download: |-
|
||||||
|
Downloading VirtualBox %{version}...
|
||||||
|
virtualbox_install_detail: |-
|
||||||
|
This may not be the latest version of VirtualBox, but it is a version
|
||||||
|
that is known to work well. Over time, we'll update the version that
|
||||||
|
is installed.
|
||||||
|
virtualbox_install_install: |-
|
||||||
|
Installing VirtualBox. This will take a few minutes...
|
||||||
|
virtualbox_install_install_detail: |-
|
||||||
|
A couple pop-ups will occur during this installation process to
|
||||||
|
ask for admin privileges as well as to install Oracle drivers.
|
||||||
|
Please say yes to both. If you're uncomfortable with this, please
|
||||||
|
install VirtualBox manually.
|
||||||
|
virtualbox_install_success: |-
|
||||||
|
VirtualBox has successfully been installed!
|
||||||
|
|
||||||
provisioners:
|
provisioners:
|
||||||
chef:
|
chef:
|
||||||
|
|
Loading…
Reference in New Issue