Class: VagrantPlugins::HostDarwin::Cap::MountSSHFS

Inherits:
Object
  • Object
show all
Extended by:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb

Constant Summary collapse

@@logger =
Log4r::Logger.new("vagrant::synced_folders::sshfs_reverse_mount")

Class Method Summary collapse

Class Method Details

.sshfs_reverse_is_folder_mounted(env, opts) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb', line 12

def self.sshfs_reverse_is_folder_mounted(env, opts)
  mounted = false
  hostpath = opts[:hostpath].dup
  hostpath.gsub!("'", "'\\\\''")
  hostpath = hostpath.chomp('/') # remove trailing / if exists
  hostpath = File.expand_path(hostpath) # get the absolute path of the file
  mount_cmd = Vagrant::Util::Which.which('mount')
  result = Vagrant::Util::Subprocess.execute(mount_cmd)
  result.stdout.each_line do |line|
    if line.split()[2] == hostpath
      mounted = true
      break
    end
  end
  return mounted
end

.sshfs_reverse_mount_folder(env, machine, opts) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb', line 29

def self.sshfs_reverse_mount_folder(env, machine, opts)
  # opts contains something like:
  #   { :type=>:sshfs,
  #     :guestpath=>"/sharedfolder",
  #     :hostpath=>"/guests/sharedfolder",
  #     :disabled=>false
  #     :ssh_host=>"192.168.1.1"
  #     :ssh_port=>"22"
  #     :ssh_username=>"username"
  #     :ssh_password=>"password"
  #   }
  self.sshfs_mount(machine, opts)
end

.sshfs_reverse_unmount_folder(env, machine, opts) ⇒ Object



43
44
45
# File 'lib/vagrant-sshfs/cap/host/darwin/sshfs_reverse_mount.rb', line 43

def self.sshfs_reverse_unmount_folder(env, machine, opts)
  self.sshfs_unmount(machine, opts)
end