Class: VagrantPlugins::SyncedFolderNFSGuest::HostBSD::Cap::UnmountNFS

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-nfs_guest_vbfix/hosts/bsd/cap/unmount_nfs.rb

Class Method Summary collapse

Class Method Details

.nfs_unmount(environment, ui, folders) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant-nfs_guest_vbfix/hosts/bsd/cap/unmount_nfs.rb', line 7

def self.nfs_unmount(environment, ui, folders)
  folders.each do |name, opts|
    if opts[:type] != :nfs_guest
      next
    end

    ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
                     guestpath: opts[:guestpath],
                     hostpath: opts[:hostpath]))

    unmount_options = opts.fetch(:unmount_options, []).join(" ")

    expanded_host_path = `printf #{opts[:hostpath]}`
    umount_msg = `umount #{unmount_options} '#{expanded_host_path}' 2>&1`

    if $?.exitstatus != 0
      if not umount_msg.include? 'not currently mounted'
        ui.info "NFS mounts still in use!"
        exit(1)
      end
    end
  end
end