Class: VagrantPlugins::Parallels::GuestDarwinCap::MountParallelsSharedFolder

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

Class Method Summary collapse

Class Method Details

.mount_parallels_shared_folder(machine, name, guestpath, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-parallels/guest_cap/darwin/mount_parallels_shared_folder.rb', line 6

def self.mount_parallels_shared_folder(machine, name, guestpath, options)
  machine.communicate.tap do |comm|
    # clear prior symlink
    if comm.test("test -L \"#{guestpath}\"", :sudo => true)
      comm.sudo("rm \"#{guestpath}\"")
    end

    # clear prior directory if exists
    if comm.test("test -d \"#{guestpath}\"", :sudo => true)
      comm.sudo("rm -Rf \"#{guestpath}\"")
    end

    # create intermediate directories if needed
    intermediate_dir = File.dirname(guestpath)
    if !comm.test("test -d \"#{intermediate_dir}\"", :sudo => true)
      comm.sudo("mkdir -p \"#{intermediate_dir}\"")
    end

    # finally make the symlink
    comm.sudo("ln -s \"/Volumes/SharedFolders/#{name}\" \"#{guestpath}\"")
  end
end

.unmount_parallels_shared_folder(machine, guestpath, options) ⇒ Object



29
30
31
# File 'lib/vagrant-parallels/guest_cap/darwin/mount_parallels_shared_folder.rb', line 29

def self.unmount_parallels_shared_folder(machine, guestpath, options)
  machine.communicate.sudo("rm #{guestpath}", error_check: false)
end