Class: VagrantPlugins::GuestLinux::Cap::MountSSHFS
- Inherits:
-
Object
- Object
- VagrantPlugins::GuestLinux::Cap::MountSSHFS
show all
- Extended by:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb
Constant Summary
collapse
- @@logger =
Log4r::Logger.new("vagrant::synced_folders::sshfs_mount")
Class Method Summary
collapse
Class Method Details
.list_mounts_command ⇒ Object
20
21
22
|
# File 'lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb', line 20
def self.list_mounts_command
"cat /proc/mounts"
end
|
.sshfs_forward_is_folder_mounted(machine, opts) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb', line 24
def self.sshfs_forward_is_folder_mounted(machine, opts)
mounted = false
guest_path = opts[:guestpath]
exists = machine.communicate.test("test -e #{guest_path}", sudo: true)
return false unless exists
absolute_guest_path = machine.guest.capability(
:sshfs_get_absolute_path, guest_path)
machine.communicate.execute(self.list_mounts_command) do |type, data|
if type == :stdout
data.each_line do |line|
if line.split()[1] == absolute_guest_path
mounted = true
break
end
end
end
end
return mounted
end
|
.sshfs_forward_mount_folder(machine, opts) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb', line 52
def self.sshfs_forward_mount_folder(machine, opts)
expanded_guest_path = machine.guest.capability(
:shell_expand_guest_path, opts[:guestpath])
machine.communicate.tap do |comm|
comm.sudo("mkdir -p #{expanded_guest_path}")
comm.sudo("chmod 777 #{expanded_guest_path}")
end
if opts[:ssh_host]
hostpath = opts[:hostpath].dup
else
hostpath = File.expand_path(opts[:hostpath], machine.env.root_path)
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
end
opts[:sshfs_opts] = ' -o allow_other ' opts[:sshfs_opts]+= ' -o noauto_cache '
opts[:ssh_opts] = ' -o StrictHostKeyChecking=no ' opts[:ssh_opts]+= ' -o ServerAliveInterval=30 '
if opts.has_key?(:ssh_host) and opts[:ssh_host]
self.sshfs_normal_mount(machine, opts, hostpath, expanded_guest_path)
else
self.sshfs_slave_mount(machine, opts, hostpath, expanded_guest_path)
end
end
|
.sshfs_forward_unmount_folder(machine, opts) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/vagrant-sshfs/cap/guest/linux/sshfs_forward_mount.rb', line 101
def self.sshfs_forward_unmount_folder(machine, opts)
expanded_guest_path = machine.guest.capability(
:shell_expand_guest_path, opts[:guestpath])
machine.ui.info(I18n.t("vagrant.sshfs.actions.unmounting_folder",
guestpath: expanded_guest_path))
error_class = VagrantPlugins::SyncedFolderSSHFS::Errors::SSHFSUnmountFailed
cmd = "umount #{expanded_guest_path}"
machine.communicate.sudo(
cmd, error_class: error_class, error_key: :unmount_failed)
end
|