diff --git a/plugins/hosts/alt/cap/nfs.rb b/plugins/hosts/alt/cap/nfs.rb new file mode 100644 index 000000000..ed68f4a92 --- /dev/null +++ b/plugins/hosts/alt/cap/nfs.rb @@ -0,0 +1,43 @@ +require "vagrant/util/subprocess" +require "vagrant/util/which" + +module VagrantPlugins + module HostALT + module Cap + class NFS + def self.nfs_check_command(env) + if systemd? + return "systemctl status --no-pager nfs-server.service" + else + return "/etc/init.d/nfs status" + end + end + + def self.nfs_start_command(env) + if systemd? + return "systemctl start rpcbind nfs-server.service" + else + return "/etc/init.d/nfs restart" + end + end + + def self.nfs_installed(environment) + if systemd? + system("systemctl --no-pager --no-legend --plain list-unit-files --all --type=service | grep --fixed-strings --quiet nfs-server.service") + else + system("rpm -q nfs-server --quiet 2>&1") + end + end + + protected + + # This tests to see if systemd is used on the system. This is used + # in newer versions of ALT, 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 diff --git a/plugins/hosts/alt/host.rb b/plugins/hosts/alt/host.rb new file mode 100644 index 000000000..2719f2b7e --- /dev/null +++ b/plugins/hosts/alt/host.rb @@ -0,0 +1,11 @@ +require "vagrant" + +module VagrantPlugins + module HostALT + class Host < Vagrant.plugin("2", :host) + def detect?(env) + File.exist?("/etc/altlinux-release") + end + end + end +end diff --git a/plugins/hosts/alt/plugin.rb b/plugins/hosts/alt/plugin.rb new file mode 100644 index 000000000..b8c8886b7 --- /dev/null +++ b/plugins/hosts/alt/plugin.rb @@ -0,0 +1,32 @@ +require "vagrant" + +module VagrantPlugins + module HostALT + class Plugin < Vagrant.plugin("2") + name "ALT Platform host" + description "ALT Platform host support." + + host("alt", "linux") do + require_relative "host" + Host + end + + host_capability("alt", "nfs_installed") do + require_relative "cap/nfs" + Cap::NFS + end + + # Linux-specific helpers we need to determine paths that can + # be overriden. + host_capability("alt", "nfs_check_command") do + require_relative "cap/nfs" + Cap::NFS + end + + host_capability("alt", "nfs_start_command") do + require_relative "cap/nfs" + Cap::NFS + end + end + end +end