Sha256: 9b5889372f9a5e16460e018f36324bdf869f3c76e6acbff042159a13d78683bf

Contents?: true

Size: 1.42 KB

Versions: 23

Compression:

Stored size: 1.42 KB

Contents

require "vagrant/util/retryable"
require "shellwords"

module VagrantPlugins
  module GuestDarwin
    module Cap
      class MountSMBSharedFolder
        extend Vagrant::Util::Retryable
        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
            # fallback to assumption that user has permission
            # to create the specified mountpoint
            machine.communicate.execute("mkdir -p #{expanded_guest_path}")
          end

          smb_password = Shellwords.shellescape(options[:smb_password])
          mount_options = options[:mount_options];
          mount_command = "mount -t smbfs " +
            (mount_options ? "-o '#{mount_options.join(",")}' " : "") +
            "'//#{options[:smb_username]}:#{smb_password}@#{options[:smb_host]}/#{name}' " +
            "#{expanded_guest_path}"
          retryable(on: Vagrant::Errors::DarwinMountFailed, tries: 10, sleep: 2) do
            machine.communicate.execute(
              mount_command,
              error_class: Vagrant::Errors::DarwinMountFailed)
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
vagrant-unbundled-2.0.1.0 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-2.0.0.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.9.8.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.9.7.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.9.5.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.9.1.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.8.5.2 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.8.5.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.8.4.2 plugins/guests/darwin/cap/mount_smb_shared_folder.rb
vagrant-unbundled-1.8.4.1 plugins/guests/darwin/cap/mount_smb_shared_folder.rb