From f2b83ac662742a8d7021f38bf7cb0fbd4f732bf3 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 24 Aug 2013 19:37:09 +0900 Subject: [PATCH 1/4] export nfs gracer way in Linux To reload /etc/exports, /sbin/exportfs is best way to command it in standard. It modify generic linux to check daemon status before restart instead of restarting everytime. Signed-off-by: Hiroshi Miura --- plugins/hosts/fedora/host.rb | 7 +++++-- plugins/hosts/gentoo/host.rb | 4 +++- plugins/hosts/linux/host.rb | 16 ++++++++++++---- plugins/hosts/opensuse/host.rb | 4 +++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/plugins/hosts/fedora/host.rb b/plugins/hosts/fedora/host.rb index 40b1ca33d..5d5c246a8 100644 --- a/plugins/hosts/fedora/host.rb +++ b/plugins/hosts/fedora/host.rb @@ -27,7 +27,7 @@ module VagrantPlugins def initialize(*args) super - @nfs_server_binary = "/etc/init.d/nfs" + nfs_server_binary = "/etc/init.d/nfs" # On Fedora 16+, systemd replaced init.d, so we have to use the # proper NFS binary. This checks to see if we need to do that. @@ -38,13 +38,16 @@ module VagrantPlugins if version_number >= 16 # "service nfs-server" will redirect properly to systemctl # when "service nfs-server restart" is called. - @nfs_server_binary = "/usr/sbin/service nfs-server" + nfs_server_binary = "/usr/sbin/service nfs-server" end end rescue Errno::ENOENT # File doesn't exist, not a big deal, assume we're on a # lower version. end + @nfs_apply_command = "/usr/sbin/exportfs -r" + @nfs_check_command = "#{nfs_server_binary} status" + @nfs_start_command = "#{nfs_server_binary} start" end end end diff --git a/plugins/hosts/gentoo/host.rb b/plugins/hosts/gentoo/host.rb index becaaf847..58179441b 100644 --- a/plugins/hosts/gentoo/host.rb +++ b/plugins/hosts/gentoo/host.rb @@ -17,7 +17,9 @@ module VagrantPlugins def initialize(*args) super - @nfs_server_binary = "/etc/init.d/nfs" + @nfs_apply_command = "/usr/sbin/exportfs -r" + @nfs_check_command = "service nfs status" + @nfs_start_command = "service nfs start" end end end diff --git a/plugins/hosts/linux/host.rb b/plugins/hosts/linux/host.rb index 265992389..56b25f95f 100644 --- a/plugins/hosts/linux/host.rb +++ b/plugins/hosts/linux/host.rb @@ -24,7 +24,9 @@ module VagrantPlugins super @logger = Log4r::Logger.new("vagrant::hosts::linux") - @nfs_server_binary = "/etc/init.d/nfs-kernel-server" + @nfs_apply_command = "/usr/sbin/exportfs -r" + @nfs_check_command = "/etc/init.d/nfs-kernel-server status" + @nfs_start_command = "/etc/init.d/nfs-kernel-server start" end def nfs? @@ -51,9 +53,11 @@ module VagrantPlugins system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"]) end - # We run restart here instead of "update" just in case nfsd - # is not starting - system("sudo #{@nfs_server_binary} restart") + if nfs_running? + system("sudo #{@nfs_apply_command}") + else + system("sudo #{@nfs_start_command}") + end end def nfs_prune(valid_ids) @@ -83,6 +87,10 @@ module VagrantPlugins protected + def nfs_running? + system("#{@nfs_check_command}") + end + def nfs_cleanup(id) return if !File.exist?("/etc/exports") diff --git a/plugins/hosts/opensuse/host.rb b/plugins/hosts/opensuse/host.rb index b560a4944..4c564bb45 100644 --- a/plugins/hosts/opensuse/host.rb +++ b/plugins/hosts/opensuse/host.rb @@ -27,7 +27,9 @@ module VagrantPlugins def initialize(*args) super - @nfs_server_binary = "/etc/init.d/nfsserver" + @nfs_apply_command = "/usr/sbin/exportfs -r" + @nfs_check_command = "service nfsserver status" + @nfs_start_command = "service nfsserver start" end end end From bae7dbb0e28b613618738f6437c8eaf5608fb19f Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sat, 24 Aug 2013 22:10:51 +0900 Subject: [PATCH 2/4] Support slackware linux Signed-off-by: Hiroshi Miura --- plugins/hosts/slackware/host.rb | 26 ++++++++++++++++++++++++++ plugins/hosts/slackware/plugin.rb | 15 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 plugins/hosts/slackware/host.rb create mode 100644 plugins/hosts/slackware/plugin.rb diff --git a/plugins/hosts/slackware/host.rb b/plugins/hosts/slackware/host.rb new file mode 100644 index 000000000..365625f39 --- /dev/null +++ b/plugins/hosts/slackware/host.rb @@ -0,0 +1,26 @@ +require "vagrant" + +require Vagrant.source_root.join("plugins/hosts/linux/host") + +module VagrantPlugins + module HostSlackware + class Host < VagrantPlugins::HostLinux::Host + def self.match? + return File.exists?("/etc/slackware-release") + end + + # Normal, mid-range precedence. + def self.precedence + 5 + end + + def initialize(*args) + super + + @nfs_apply_command = "/usr/sbin/exportfs -r" + @nfs_check_command = "/etc/rc.d/rc.nfsd status" + @nfs_start_command = "/etc/rc.d/rc.nfsd start" + end + end + end +end diff --git a/plugins/hosts/slackware/plugin.rb b/plugins/hosts/slackware/plugin.rb new file mode 100644 index 000000000..d99f622c9 --- /dev/null +++ b/plugins/hosts/slackware/plugin.rb @@ -0,0 +1,15 @@ +require "vagrant" + +module VagrantPlugins + module HostGentoo + class Plugin < Vagrant.plugin("2") + name "Slackware host" + description "Slackware and derivertives host support." + + host("slackware") do + require File.expand_path("../host", __FILE__) + Host + end + end + end +end From 3d886671a60c836982032a4e834e2c4a20d36e73 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 25 Aug 2013 00:10:18 +0900 Subject: [PATCH 3/4] fix typo for slackware Signed-off-by: Hiroshi Miura --- plugins/hosts/slackware/plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hosts/slackware/plugin.rb b/plugins/hosts/slackware/plugin.rb index d99f622c9..8c5e1595b 100644 --- a/plugins/hosts/slackware/plugin.rb +++ b/plugins/hosts/slackware/plugin.rb @@ -1,7 +1,7 @@ require "vagrant" module VagrantPlugins - module HostGentoo + module HostSlackware class Plugin < Vagrant.plugin("2") name "Slackware host" description "Slackware and derivertives host support." From 05d27d20e4a3d2b036d7731ce9b66ac2bc844ab7 Mon Sep 17 00:00:00 2001 From: KATOH Yasufumi Date: Mon, 26 Aug 2013 16:56:12 +0900 Subject: [PATCH 4/4] improve slackware/plamo detection and change nfs_check_command * On Slackware, /etc/rc.d/rc.nfsd has no "status" argument, so the check command change to pidof command. * On Plamo Linux, there is no /etc/slackware-release file, so use "/usr/lib/setup/Plamo-*" instead. --- plugins/hosts/slackware/host.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/hosts/slackware/host.rb b/plugins/hosts/slackware/host.rb index 365625f39..65345280b 100644 --- a/plugins/hosts/slackware/host.rb +++ b/plugins/hosts/slackware/host.rb @@ -6,7 +6,7 @@ module VagrantPlugins module HostSlackware class Host < VagrantPlugins::HostLinux::Host def self.match? - return File.exists?("/etc/slackware-release") + return File.exists?("/etc/slackware-release") || Dir.glob("/usr/lib/setup/Plamo-*").length > 0 end # Normal, mid-range precedence. @@ -18,7 +18,7 @@ module VagrantPlugins super @nfs_apply_command = "/usr/sbin/exportfs -r" - @nfs_check_command = "/etc/rc.d/rc.nfsd status" + @nfs_check_command = "pidof nfsd > /dev/null" @nfs_start_command = "/etc/rc.d/rc.nfsd start" end end