summaryrefslogtreecommitdiff
path: root/lib/chef/platform
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-25 22:14:34 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-28 17:34:55 -0700
commitb8cffc2e35c662585acff290b27f072c60105479 (patch)
tree5ad0dec08499bf48c9b29e3122d9b96587c75ec7 /lib/chef/platform
parent68656820438b84d433ae9015b953790f67ddf0ec (diff)
downloadchef-b8cffc2e35c662585acff290b27f072c60105479.tar.gz
Add test for nonzero systemctl exit code
Diffstat (limited to 'lib/chef/platform')
-rw-r--r--lib/chef/platform/service_helpers.rb23
1 files changed, 12 insertions, 11 deletions
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)