hosts/alt: Add hosts capabilities for ALT Linux platforms

This commit is contained in:
Evgeny Sinelnikov 2017-07-08 21:36:18 +03:00
parent 88c0cb855f
commit 26f7a04b86
3 changed files with 86 additions and 0 deletions

View File

@ -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

11
plugins/hosts/alt/host.rb Normal file
View File

@ -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

View File

@ -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