Skip to content

Commit

Permalink
Merge pull request #235 from legal90/darwin-install_parallels_tools
Browse files Browse the repository at this point in the history
Add "install_parallels_tools" guest cap for Darwin guests
  • Loading branch information
legal90 committed Nov 24, 2015
2 parents 4aa901b + bc98daf commit a2601f9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
34 changes: 34 additions & 0 deletions lib/vagrant-parallels/guest_cap/darwin/install_parallels_tools.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module VagrantPlugins
module Parallels
module GuestDarwinCap
class InstallParallelsTools

def self.install_parallels_tools(machine)
machine.communicate.tap do |comm|
tools_iso_path = File.expand_path(
machine.provider.driver.read_guest_tools_iso_path('darwin'),
machine.env.root_path
)
remote_file = '/tmp/prl-tools-mac.iso'
mount_point = "/media/prl-tools-lin_#{rand(100000)}/"

comm.upload(tools_iso_path, remote_file)

# Create mount point directory if needed
if !comm.test("test -d \"#{mount_point}\"", :sudo => true)
comm.sudo("mkdir -p \"#{mount_point}\"")
end

# Mount ISO and install Parallels Tools
comm.sudo("hdiutil attach #{remote_file} -mountpoint #{mount_point}")
comm.sudo("installer -pkg '#{mount_point}/Install.app/Contents/Resources/Install.mpkg' -target /")
comm.sudo("hdiutil detach '#{mount_point}'")

comm.sudo("rm -Rf \"#{mount_point}\"")
comm.sudo("rm -f \"#{remote_file}\"")
end
end
end
end
end
end
5 changes: 5 additions & 0 deletions lib/vagrant-parallels/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class Plugin < Vagrant.plugin('2')
Config
end

guest_capability(:darwin, :install_parallels_tools) do
require_relative 'guest_cap/darwin/install_parallels_tools'
GuestDarwinCap::InstallParallelsTools
end

guest_capability(:darwin, :mount_parallels_shared_folder) do
require_relative 'guest_cap/darwin/mount_parallels_shared_folder'
GuestDarwinCap::MountParallelsSharedFolder
Expand Down
4 changes: 2 additions & 2 deletions website/docs/source/docs/configuration.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ delete your boxes carefully!
## Parallels Tools Auto-Update
<div class="alert alert-info">
<p>
<strong>Note:</strong> This feature makes sense to Linux guests only.
In Windows and Mac OS guests Parallels Tools will be always updated
<strong>Note:</strong> This feature makes sense to Linux and OS X guests
only. In Windows guests Parallels Tools will be always updated
automatically by the special installation agent running in GUI mode.
</p>
</div>
Expand Down

0 comments on commit a2601f9

Please # to comment.