Class: VagrantPlugins::Parallels::GuestLinuxCap::InstallParallelsTools

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb

Class Method Summary collapse

Class Method Details

.install_parallels_tools(machine) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb', line 8

def self.install_parallels_tools(machine)
  if ptiagent_usable?(machine)
    machine.communicate.sudo('ptiagent-cmd --install')
  else
    machine.communicate.tap do |comm|
      arch = ''
      comm.execute("uname -p") { |type, data| arch << data if type == :stdout }

      tools_iso_path = File.expand_path(
        machine.provider.driver.read_guest_tools_iso_path("linux", arch),
        machine.env.root_path
      )
      remote_file = '/tmp/prl-tools-lin.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("mount -o loop #{remote_file} #{mount_point}")
      comm.sudo("#{mount_point}/install --install-unattended-with-deps")
      comm.sudo("umount -f \"#{mount_point}\"")

      comm.sudo("rm -Rf \"#{mount_point}\"")
      comm.sudo("rm -f \"#{remote_file}\"")
    end
  end
end

.ptiagent_usable?(machine) ⇒ Boolean

This helper detects is Parallels Tools Installation Agent (PTIAgent) available and can be used

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
# File 'lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb', line 45

def self.ptiagent_usable?(machine)
  # Parallels Desktop 9 or higher should be installed on the host and
  # 'ptiagent-cmd' binary should be available on the guest

  machine.provider_name == :parallels &&
  Gem::Version.new(machine.provider.driver.version) >= Gem::Version.new('9') &&
  machine.communicate.test('which ptiagent-cmd', :sudo => true)
end