Sha256: 92f6251b083d4147775471e7c5659686acce5e6895901796115f61fa7aa6d2b1

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require "vagrant/util/template_renderer"
require "vagrant-guest-msys2/util/cap_helpers"

module VagrantPlugins
  module GuestMSYS2
    module Cap
      class MountSharedFolder
        def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
          mount_shared_folder(machine, name, guestpath, "\\\\vboxsrv\\")
        end

        def self.mount_vmware_shared_folder(machine, name, guestpath, options)
          mount_shared_folder(machine, name, guestpath, "\\\\vmware-host\\Shared Folders\\")
        end

        def self.mount_parallels_shared_folder(machine, name, guestpath, options)
          mount_shared_folder(machine, name, guestpath, "\\\\psf\\")
        end

        def self.mount_smb_shared_folder(machine, name, guestpath, options)
          machine.communicate.execute("cmdkey -add:#{options[:smb_host]} -user:#{options[:smb_username]} -pass:#{options[:smb_password]}")
          mount_shared_folder(machine, name, guestpath, "\\\\#{options[:smb_host]}\\")
        end

        protected

        def self.mount_shared_folder(machine, name, guestpath, vm_provider_unc_base)
          name = name.gsub(/[\/\/]/,'_').sub(/^_/, '')
          path = File.expand_path("../../scripts/mount_volume.ps1", __FILE__)
          script = Vagrant::Util::TemplateRenderer.render(path, options: {
            mount_point: guestpath,
            share_name: name,
            vm_provider_unc_path: vm_provider_unc_base + name,
          })
          machine.communicate.execute(Util::CapHelpers.wrap_powershell(script))
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-guest-msys2-0.0.6 lib/vagrant-guest-msys2/cap/mount_shared_folder.rb
vagrant-guest-msys2-0.0.5 lib/vagrant-guest-msys2/cap/mount_shared_folder.rb