many more hosts converted

This commit is contained in:
Mitchell Hashimoto 2014-01-07 21:11:59 -08:00
parent 4cec8b48d9
commit 4d47dae5b9
13 changed files with 181 additions and 118 deletions

View File

@ -18,11 +18,6 @@ module VagrantPlugins
# Linux-specific helpers we need to determine paths that can
# be overriden.
host_capability("arch", "nfs_apply_command") do
require_relative "cap/nfs"
Cap::NFS
end
host_capability("arch", "nfs_check_command") do
require_relative "cap/nfs"
Cap::NFS

View File

@ -0,0 +1,34 @@
require "vagrant/util/subprocess"
module VagrantPlugins
module HostGentoo
module Cap
class NFS
def self.nfs_check_command(env)
if systemd?
return "/usr/sbin/systemctl status nfsd"
else
return "/etc/init.d/nfs status"
end
end
def self.nfs_start_command(env)
if systemd?
return "/usr/sbin/systemctl start nfsd rpc-mountd rpcbind"
else
return "/etc/init.d/nfs restart"
end
end
protected
# This tests to see if systemd is used on the system. This is used
# in newer versions of Arch, and requires a change in behavior.
def self.systemd?
result = Vagrant::Util::Subprocess.execute("ps", "-o", "comm=", "1")
return result.stdout.chomp == "systemd"
end
end
end
end
end

View File

@ -1,39 +1,10 @@
require "vagrant"
require "vagrant/util/subprocess"
require Vagrant.source_root.join("plugins/hosts/linux/host")
module VagrantPlugins
module HostGentoo
class Host < VagrantPlugins::HostLinux::Host
def self.match?
return File.exists?("/etc/gentoo-release")
end
# Normal, mid-range precedence.
def self.precedence
5
end
def initialize(*args)
super
@nfs_apply_command = "/usr/sbin/exportfs -r"
if systemd?
@nfs_check_command = "/usr/bin/systemctl status nfsd"
@nfs_start_command = "/usr/bin/systemctl start nfsd rpc-mountd rpcbind"
else
@nfs_check_command = "/etc/init.d/nfs status"
@nfs_start_command = "/etc/init.d/nfs restart"
end
end
protected
# Check for systemd presence from current processes.
def systemd?
result = Vagrant::Util::Subprocess.execute("ps", "-o", "comm=", "1")
return result.stdout.chomp == "systemd"
class Host < Vagrant.plugin("2", :host)
def self.detect?(env)
File.exists?("/etc/gentoo-release")
end
end
end

View File

@ -6,10 +6,23 @@ module VagrantPlugins
name "Gentoo host"
description "Gentoo host support."
host("gentoo") do
require File.expand_path("../host", __FILE__)
host("gentoo", "linux") do
require_relative "host"
Host
end
# Linux-specific helpers we need to determine paths that can
# be overriden.
host_capability("gentoo", "nfs_check_command") do
require_relative "cap/nfs"
Cap::NFS
end
host_capability("gentoo", "nfs_start_command") do
require_relative "cap/nfs"
Cap::NFS
end
end
end
end

View File

@ -0,0 +1,15 @@
module VagrantPlugins
module HostOpenSUSE
module Cap
class NFS
def self.nfs_check_command(env)
"service nfsserver status"
end
def self.nfs_start_command(env)
"service nfsserver start"
end
end
end
end
end

View File

@ -2,12 +2,10 @@ require "pathname"
require "vagrant"
require Vagrant.source_root.join("plugins/hosts/linux/host")
module VagrantPlugins
module HostOpenSUSE
class Host < VagrantPlugins::HostLinux::Host
def self.match?
class Host < Vagrant.plugin("2", :host)
def self.detect?(env)
release_file = Pathname.new("/etc/SuSE-release")
if release_file.exist?
@ -18,19 +16,6 @@ module VagrantPlugins
false
end
# Normal, mid-range precedence.
def self.precedence
5
end
def initialize(*args)
super
@nfs_apply_command = "/usr/sbin/exportfs -r"
@nfs_check_command = "service nfsserver status"
@nfs_start_command = "service nfsserver start"
end
end
end
end

View File

@ -6,10 +6,22 @@ module VagrantPlugins
name "OpenSUSE host"
description "OpenSUSE host support."
host("opensuse") do
require File.expand_path("../host", __FILE__)
host("opensuse", "linux") do
require_relative "host"
Host
end
# Linux-specific helpers we need to determine paths that can
# be overriden.
host_capability("opensuse", "nfs_check_command") do
require_relative "cap/nfs"
Cap::NFS
end
host_capability("opensuse", "nfs_start_command") do
require_relative "cap/nfs"
Cap::NFS
end
end
end
end

View File

@ -0,0 +1,45 @@
require "pathname"
module VagrantPlugins
module HostRedHat
module Cap
class NFS
def self.nfs_check_command(env)
"#{nfs_server_binary} status"
end
def self.nfs_start_command(env)
"#{nfs_server_binary} start"
end
protected
def self.nfs_server_binary
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.
release_file = Pathname.new("/etc/redhat-release")
begin
release_file.open("r:ISO-8859-1:UTF-8") do |f|
fedora_match = /Fedora.* release ([0-9]+)/.match(f.gets)
if fedora_match
version_number = fedora_match[1].to_i
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"
end
end
end
rescue Errno::ENOENT
# File doesn't exist, not a big deal, assume we're on a
# lower version.
end
nfs_server_binary
end
end
end
end
end

View File

@ -2,12 +2,10 @@ require "pathname"
require "vagrant"
require Vagrant.source_root.join("plugins/hosts/linux/host")
module VagrantPlugins
module HostRedHat
class Host < VagrantPlugins::HostLinux::Host
def self.match?
class Host < Vagrant.plugin("2", :host)
def self.detect?(env)
release_file = Pathname.new("/etc/redhat-release")
if release_file.exist?
@ -15,47 +13,17 @@ module VagrantPlugins
contents = f.gets
return true if contents =~ /^Fedora/ # Fedora
return true if contents =~ /^CentOS/ # CentOS
return true if contents =~ /^Enterprise Linux Enterprise Linux/ # Oracle Linux < 5.3
return true if contents =~ /^Red Hat Enterprise Linux/ # Red Hat Enterprise Linux and Oracle Linux >= 5.3
# Oracle Linux < 5.3
return true if contents =~ /^Enterprise Linux Enterprise Linux/
# Red Hat Enterprise Linux and Oracle Linux >= 5.3
return true if contents =~ /^Red Hat Enterprise Linux/
end
end
false
end
# Normal, mid-range precedence.
def self.precedence
5
end
def initialize(*args)
super
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.
release_file = Pathname.new("/etc/redhat-release")
begin
release_file.open("r:ISO-8859-1:UTF-8") do |f|
fedora_match = /Fedora.* release ([0-9]+)/.match(f.gets)
if fedora_match
version_number = fedora_match[1].to_i
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"
end
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
end

View File

@ -6,10 +6,22 @@ module VagrantPlugins
name "Red Hat host"
description "Red Hat host support."
host("redhat") do
host("redhat", "linux") do
require File.expand_path("../host", __FILE__)
Host
end
# Linux-specific helpers we need to determine paths that can
# be overriden.
host_capability("redhat", "nfs_check_command") do
require_relative "cap/nfs"
Cap::NFS
end
host_capability("redhat", "nfs_start_command") do
require_relative "cap/nfs"
Cap::NFS
end
end
end
end

View File

@ -0,0 +1,15 @@
module VagrantPlugins
module HostSlackware
module Cap
class NFS
def self.nfs_check_command(env)
"pidof nfsd >/dev/null"
end
def self.nfs_start_command(env)
"/etc/rc.d/rc.nfsd start"
end
end
end
end
end

View File

@ -1,25 +1,11 @@
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") || Dir.glob("/usr/lib/setup/Plamo-*").length > 0
end
# Normal, mid-range precedence.
def self.precedence
5
end
def initialize(*args)
super
@nfs_apply_command = "/usr/sbin/exportfs -r"
@nfs_check_command = "pidof nfsd > /dev/null"
@nfs_start_command = "/etc/rc.d/rc.nfsd start"
class Host < Vagrant.plugin("2", :host)
def self.detect?(env)
return File.exists?("/etc/slackware-release") ||
!Dir.glob("/usr/lib/setup/Plamo-*").empty?
end
end
end

View File

@ -6,10 +6,22 @@ module VagrantPlugins
name "Slackware host"
description "Slackware and derivertives host support."
host("slackware") do
host("slackware", "linux") do
require File.expand_path("../host", __FILE__)
Host
end
# Linux-specific helpers we need to determine paths that can
# be overriden.
host_capability("slackware", "nfs_check_command") do
require_relative "cap/nfs"
Cap::NFS
end
host_capability("slackware", "nfs_start_command") do
require_relative "cap/nfs"
Cap::NFS
end
end
end
end