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 <miurahr@linux.com>
This commit is contained in:
parent
0dfc6455ae
commit
f2b83ac662
|
@ -27,7 +27,7 @@ module VagrantPlugins
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
super
|
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
|
# 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.
|
# proper NFS binary. This checks to see if we need to do that.
|
||||||
|
@ -38,13 +38,16 @@ module VagrantPlugins
|
||||||
if version_number >= 16
|
if version_number >= 16
|
||||||
# "service nfs-server" will redirect properly to systemctl
|
# "service nfs-server" will redirect properly to systemctl
|
||||||
# when "service nfs-server restart" is called.
|
# 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
|
||||||
end
|
end
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
# File doesn't exist, not a big deal, assume we're on a
|
# File doesn't exist, not a big deal, assume we're on a
|
||||||
# lower version.
|
# lower version.
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,9 @@ module VagrantPlugins
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
super
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,9 @@ module VagrantPlugins
|
||||||
super
|
super
|
||||||
|
|
||||||
@logger = Log4r::Logger.new("vagrant::hosts::linux")
|
@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
|
end
|
||||||
|
|
||||||
def nfs?
|
def nfs?
|
||||||
|
@ -51,9 +53,11 @@ module VagrantPlugins
|
||||||
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
||||||
end
|
end
|
||||||
|
|
||||||
# We run restart here instead of "update" just in case nfsd
|
if nfs_running?
|
||||||
# is not starting
|
system("sudo #{@nfs_apply_command}")
|
||||||
system("sudo #{@nfs_server_binary} restart")
|
else
|
||||||
|
system("sudo #{@nfs_start_command}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def nfs_prune(valid_ids)
|
def nfs_prune(valid_ids)
|
||||||
|
@ -83,6 +87,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def nfs_running?
|
||||||
|
system("#{@nfs_check_command}")
|
||||||
|
end
|
||||||
|
|
||||||
def nfs_cleanup(id)
|
def nfs_cleanup(id)
|
||||||
return if !File.exist?("/etc/exports")
|
return if !File.exist?("/etc/exports")
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,9 @@ module VagrantPlugins
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
super
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue