Class: VagrantPlugins::SyncedFolderNFSGuest::HostLinux::Cap::UnmountNFS

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-nfs_guest/hosts/linux/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
# File 'lib/vagrant-nfs_guest/hosts/linux/cap/unmount_nfs.rb', line 7

def self.nfs_unmount(environment, ui, folders)
  folders.each do |name, opts|
    ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
                     guestpath: opts[:guestpath],
                     hostpath: opts[:hostpath]))

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

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

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