From fbd8cfc628aa48b5fe1eaa0ee1636cb74a43ee11 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 18 Jan 2014 11:03:46 -0800 Subject: [PATCH] hosts/gentoo: more robust check for systemctl path on Gentoo --- plugins/hosts/gentoo/cap/nfs.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/hosts/gentoo/cap/nfs.rb b/plugins/hosts/gentoo/cap/nfs.rb index 5dd2275bf..2cdbd35bd 100644 --- a/plugins/hosts/gentoo/cap/nfs.rb +++ b/plugins/hosts/gentoo/cap/nfs.rb @@ -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