From b8cffc2e35c662585acff290b27f072c60105479 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Fri, 25 Sep 2015 22:14:34 -0700 Subject: Add test for nonzero systemctl exit code --- lib/chef/platform/service_helpers.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'lib/chef/platform') diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb index 6b44478725..8a840b91c3 100644 --- a/lib/chef/platform/service_helpers.rb +++ b/lib/chef/platform/service_helpers.rb @@ -19,6 +19,7 @@ # XXX: mixing shellout into a mixin into classes has to be code smell require 'chef/mixin/shell_out' require 'chef/mixin/which' +require 'chef/chef_class' class Chef class Platform @@ -44,24 +45,24 @@ class Chef def service_resource_providers @service_resource_providers ||= [].tap do |service_resource_providers| - if ::File.exist?("/usr/sbin/update-rc.d") + if ::File.exist?(Chef.path_to("/usr/sbin/update-rc.d")) service_resource_providers << :debian end - if ::File.exist?("/usr/sbin/invoke-rc.d") + if ::File.exist?(Chef.path_to("/usr/sbin/invoke-rc.d")) service_resource_providers << :invokercd end - if ::File.exist?("/sbin/insserv") + if ::File.exist?(Chef.path_to("/sbin/insserv")) service_resource_providers << :insserv end # debian >= 6.0 has /etc/init but does not have upstart - if ::File.exist?("/etc/init") && ::File.exist?("/sbin/start") + if ::File.exist?(Chef.path_to("/etc/init")) && ::File.exist?(Chef.path_to("/sbin/start")) service_resource_providers << :upstart end - if ::File.exist?("/sbin/chkconfig") + if ::File.exist?(Chef.path_to("/sbin/chkconfig")) service_resource_providers << :redhat end @@ -75,23 +76,23 @@ class Chef def config_for_service(service_name) configs = [] - if ::File.exist?("/etc/init.d/#{service_name}") + if ::File.exist?(Chef.path_to("/etc/init.d/#{service_name}")) configs << :initd end - if ::File.exist?("/etc/init/#{service_name}.conf") + if ::File.exist?(Chef.path_to("/etc/init/#{service_name}.conf")) configs << :upstart end - if ::File.exist?("/etc/xinetd.d/#{service_name}") + if ::File.exist?(Chef.path_to("/etc/xinetd.d/#{service_name}")) configs << :xinetd end - if ::File.exist?("/etc/rc.d/#{service_name}") + if ::File.exist?(Chef.path_to("/etc/rc.d/#{service_name}")) configs << :etc_rcd end - if ::File.exist?("/usr/local/etc/rc.d/#{service_name}") + if ::File.exist?(Chef.path_to("/usr/local/etc/rc.d/#{service_name}")) configs << :usr_local_etc_rcd end @@ -117,7 +118,7 @@ class Chef end def systemd_sanity_check? - systemctl_path && File.exist?("/proc/1/comm") && File.open("/proc/1/comm").gets.chomp == "systemd" + systemctl_path && File.exist?(Chef.path_to("/proc/1/comm")) && File.open(Chef.path_to("/proc/1/comm")).gets.chomp == "systemd" end def extract_systemd_services(command) -- cgit v1.2.1