Class: VagrantPlugins::HostLinux::Cap::MountSSHFS

Inherits:
Object
  • Object
show all
Extended by:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-sshfs/cap/host/linux/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
# File 'lib/vagrant-sshfs/cap/host/linux/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
  mounts = File.open('/proc/mounts', 'r')
  mounts.each_line do |line|
    if line.split()[1] == hostpath
      mounted = true
      break
    end
  end
  return mounted
end

.sshfs_reverse_mount_folder(env, machine, opts) ⇒ Object



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

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



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

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