2012-04-19 05:20:45 +00:00
|
|
|
require "pathname"
|
2011-12-12 07:22:44 +00:00
|
|
|
|
2012-05-23 23:03:14 +00:00
|
|
|
require "vagrant"
|
|
|
|
|
|
|
|
require Vagrant.source_root.join("plugins/hosts/linux/host")
|
|
|
|
|
2012-04-19 05:20:45 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module HostFedora
|
|
|
|
class Host < VagrantPlugins::HostLinux::Host
|
2011-12-12 07:22:44 +00:00
|
|
|
def self.match?
|
|
|
|
release_file = Pathname.new("/etc/redhat-release")
|
|
|
|
|
|
|
|
if release_file.exist?
|
|
|
|
release_file.open("r") do |f|
|
2013-07-18 15:23:46 +00:00
|
|
|
contents = f.gets
|
|
|
|
return true if contents =~ /^Fedora/
|
|
|
|
return true if contents =~ /^CentOS/
|
2013-08-28 07:01:27 +00:00
|
|
|
return true if contents =~ /^Red Hat Enterprise Linux Server/
|
2011-12-12 07:22:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2012-01-25 18:39:17 +00:00
|
|
|
# Normal, mid-range precedence.
|
|
|
|
def self.precedence
|
|
|
|
5
|
|
|
|
end
|
|
|
|
|
2011-08-28 06:47:13 +00:00
|
|
|
def initialize(*args)
|
|
|
|
super
|
|
|
|
|
2013-08-24 10:37:09 +00:00
|
|
|
nfs_server_binary = "/etc/init.d/nfs"
|
2012-09-19 05:19:51 +00:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
release_file = Pathname.new("/etc/redhat-release")
|
|
|
|
begin
|
|
|
|
release_file.open("r") do |f|
|
2013-08-28 07:01:27 +00:00
|
|
|
version_number = /(CentOS|Fedora|Red Hat Enterprise Linux Server).*release ([0-9]+)/.match(f.gets)[2].to_i
|
2012-09-19 05:19:51 +00:00
|
|
|
if version_number >= 16
|
|
|
|
# "service nfs-server" will redirect properly to systemctl
|
|
|
|
# when "service nfs-server restart" is called.
|
2013-08-24 10:37:09 +00:00
|
|
|
nfs_server_binary = "/usr/sbin/service nfs-server"
|
2012-09-19 05:19:51 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
# File doesn't exist, not a big deal, assume we're on a
|
|
|
|
# lower version.
|
|
|
|
end
|
2013-08-24 10:37:09 +00:00
|
|
|
@nfs_apply_command = "/usr/sbin/exportfs -r"
|
|
|
|
@nfs_check_command = "#{nfs_server_binary} status"
|
|
|
|
@nfs_start_command = "#{nfs_server_binary} start"
|
2011-08-28 06:47:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|