Sha256: 79dc4914c1f0fc964001d5b78b193e95bc161332110266826b105383517fbf35

Contents?: true

Size: 1.93 KB

Versions: 24

Compression:

Stored size: 1.93 KB

Contents

module VagrantPlugins
  module Parallels
    module GuestLinuxCap
      class InstallParallelsTools

        def self.install_parallels_tools(machine)
          if ptiagent_usable?(machine)
            # Argument '--info' means that Parallels Tools version will be
            # checked before the installing.
            machine.communicate.sudo("ptiagent-cmd --info")
          else
            machine.communicate.tap do |comm|
              tools_iso_path = File.expand_path(
                machine.provider.driver.read_guest_tools_iso_path("linux"),
                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

        private

        # This helper detects is Parallels Tools Installation Agent (PTIAgent)
        # available and can be used
        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
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
vagrant-parallels-1.4.2 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.4.1 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.4.0 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.4.0.rc1 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.13 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.12 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.10 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.9 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.8 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.7 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.6 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.5 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.4 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.3 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.3.rc1 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.2 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.1 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.3.0 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.2.2 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb
vagrant-parallels-1.2.1 lib/vagrant-parallels/guest_cap/linux/install_parallels_tools.rb