13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/vagrant-darwin-smb/cap/mount_smb_shared_folder.rb', line 13
def self.mount_smb_shared_folder(machine, name, guestpath, options)
expanded_guest_path = machine.guest.capability(:shell_expand_guest_path, guestpath)
mount_point_owner = options[:owner];
if mount_point_owner
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
machine.communicate.sudo("chown #{mount_point_owner} #{expanded_guest_path}")
else
machine.communicate.execute("mkdir -p #{expanded_guest_path}")
end
smb_password = Shellwords.shellescape(options[:smb_password])
mount_opts = options[:mount_options];
mount_command = "mount -t smbfs " +
(mount_opts ? "-o '#{mount_opts.join(",")}' " : "") +
"'//#{options[:smb_username]}:#{smb_password}@#{options[:smb_host]}/#{name}' " +
"#{expanded_guest_path}"
retryable(on: Errors::DarwinMountFailed, tries: 10, sleep: 2) do
machine.communicate.execute(
mount_command,
error_class: Errors::DarwinMountFailed)
end
end
|