From c4776e4e1de41e388f8378242cb1810bc4013761 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 4 Feb 2016 16:19:53 +0100 Subject: [PATCH 1/5] added tinycore nfs mount cap --- plugins/guests/tinycore/plugin.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/guests/tinycore/plugin.rb b/plugins/guests/tinycore/plugin.rb index 3febbb16f..a2b6a1ccd 100644 --- a/plugins/guests/tinycore/plugin.rb +++ b/plugins/guests/tinycore/plugin.rb @@ -30,6 +30,11 @@ module VagrantPlugins require_relative "cap/rsync" Cap::RSync end + + guest_capability("linux", "mount_nfs_folder") do + require_relative "cap/mount_nfs" + Cap::MountNFS + end end end end From a7bdfd682e78cc925790ba1d5fb2466e1d5efec1 Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 4 Feb 2016 16:21:07 +0100 Subject: [PATCH 2/5] added tinycore nfs mount cap --- plugins/guests/tinycore/cap/mount_nfs.rb | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 plugins/guests/tinycore/cap/mount_nfs.rb diff --git a/plugins/guests/tinycore/cap/mount_nfs.rb b/plugins/guests/tinycore/cap/mount_nfs.rb new file mode 100644 index 000000000..26dfb625d --- /dev/null +++ b/plugins/guests/tinycore/cap/mount_nfs.rb @@ -0,0 +1,46 @@ +require "vagrant/util/retryable" + +module VagrantPlugins + module GuestLinux + module Cap + class MountNFS + extend Vagrant::Util::Retryable + + def self.mount_nfs_folder(machine, ip, folders) + folders.each do |name, opts| + # Expand the guest path so we can handle things like "~/vagrant" + expanded_guest_path = machine.guest.capability( + :shell_expand_guest_path, opts[:guestpath]) + + # Do the actual creating and mounting + machine.communicate.sudo("mkdir -p #{expanded_guest_path}") + + # Mount + hostpath = opts[:hostpath].dup + hostpath.gsub!("'", "'\\\\''") + + # Figure out any options + mount_opts = ["vers=#{opts[:nfs_version]}"] + mount_opts << "udp" if opts[:nfs_udp] + if opts[:mount_options] + mount_opts = opts[:mount_options].dup + end + + mount_command = "mount -o '#{mount_opts.join(",")}' #{ip}:'#{hostpath}' #{expanded_guest_path}" + retryable(on: Vagrant::Errors::LinuxNFSMountFailed, tries: 8, sleep: 3) do + machine.communicate.sudo(mount_command, + error_class: Vagrant::Errors::LinuxNFSMountFailed) + end + + # Emit an upstart event if we can + machine.communicate.sudo <<-SCRIPT +if command -v /sbin/init &>/dev/null && /sbin/init --version | grep upstart &>/dev/null; then + /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT='#{expanded_guest_path}' +fi +SCRIPT + end + end + end + end + end +end From 25b913e1c1a96dcb70bd0e78fd938037873d46da Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 4 Feb 2016 16:26:37 +0100 Subject: [PATCH 3/5] added tinycore nfs mount cap --- plugins/guests/tinycore/plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/tinycore/plugin.rb b/plugins/guests/tinycore/plugin.rb index a2b6a1ccd..3598d7d9b 100644 --- a/plugins/guests/tinycore/plugin.rb +++ b/plugins/guests/tinycore/plugin.rb @@ -31,7 +31,7 @@ module VagrantPlugins Cap::RSync end - guest_capability("linux", "mount_nfs_folder") do + guest_capability("tinycore", "mount_nfs_folder") do require_relative "cap/mount_nfs" Cap::MountNFS end From 833f2d0ef7e58decb72701ed0172c87f197c2aca Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 4 Feb 2016 16:27:53 +0100 Subject: [PATCH 4/5] added tinycore nfs mount cap --- plugins/guests/tinycore/cap/mount_nfs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/tinycore/cap/mount_nfs.rb b/plugins/guests/tinycore/cap/mount_nfs.rb index 26dfb625d..5c2cde27e 100644 --- a/plugins/guests/tinycore/cap/mount_nfs.rb +++ b/plugins/guests/tinycore/cap/mount_nfs.rb @@ -1,7 +1,7 @@ require "vagrant/util/retryable" module VagrantPlugins - module GuestLinux + module GuestTinyCore module Cap class MountNFS extend Vagrant::Util::Retryable From dd541b93b909f95f39b59c4d18957e73faf2b74b Mon Sep 17 00:00:00 2001 From: Dennis Date: Thu, 4 Feb 2016 17:22:28 +0100 Subject: [PATCH 5/5] ooops missed something while branching --- plugins/guests/tinycore/cap/mount_nfs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/tinycore/cap/mount_nfs.rb b/plugins/guests/tinycore/cap/mount_nfs.rb index 5c2cde27e..ccfc1666b 100644 --- a/plugins/guests/tinycore/cap/mount_nfs.rb +++ b/plugins/guests/tinycore/cap/mount_nfs.rb @@ -26,7 +26,7 @@ module VagrantPlugins mount_opts = opts[:mount_options].dup end - mount_command = "mount -o '#{mount_opts.join(",")}' #{ip}:'#{hostpath}' #{expanded_guest_path}" + mount_command = "mount.nfs -o '#{mount_opts.join(",")}' #{ip}:'#{hostpath}' #{expanded_guest_path}" retryable(on: Vagrant::Errors::LinuxNFSMountFailed, tries: 8, sleep: 3) do machine.communicate.sudo(mount_command, error_class: Vagrant::Errors::LinuxNFSMountFailed)