hosts/gentoo: more robust check for systemctl path on Gentoo

This commit is contained in:
Mitchell Hashimoto 2014-01-18 11:03:46 -08:00
parent 663a942a93
commit fbd8cfc628
1 changed files with 14 additions and 2 deletions

View File

@ -1,4 +1,5 @@
require "vagrant/util/subprocess"
require "vagrant/util/which"
module VagrantPlugins
module HostGentoo
@ -6,7 +7,7 @@ module VagrantPlugins
class NFS
def self.nfs_check_command(env)
if systemd?
return "/usr/bin/systemctl status nfsd"
return "#{systemctl_path} status nfsd"
else
return "/etc/init.d/nfs status"
end
@ -14,7 +15,7 @@ module VagrantPlugins
def self.nfs_start_command(env)
if systemd?
return "/usr/bin/systemctl start nfsd rpc-mountd rpcbind"
return "#{systemctl_path} start nfsd rpc-mountd rpcbind"
else
return "/etc/init.d/nfs restart"
end
@ -28,6 +29,17 @@ module VagrantPlugins
result = Vagrant::Util::Subprocess.execute("ps", "-o", "comm=", "1")
return result.stdout.chomp == "systemd"
end
def self.systemctl_path
path = Vagrant::Util::Which.which("systemctl")
return path if path
folders = ["/usr/bin", "/usr/sbin"]
folders.each do |folder|
path = "#{folder}/systemctl"
return path if File.file?(path)
end
end
end
end
end