diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/provider/service/redhat.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index e599e63f1..45db9f193 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -4,15 +4,15 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do desc "Red Hat's (and probably many others) form of ``init``-style service management; uses ``chkconfig`` for service enabling and disabling." - confine :exists => "/sbin/chkconfig" + commands :chkconfig => "/sbin/chkconfig" - defaultfor :operatingsystem => [:redhat, :fedora] + defaultfor :operatingsystem => [:redhat, :fedora, :suse] # Remove the symlinks def disable begin - output = util_execute("/sbin/chkconfig #{@model[:name]} off 2>&1") - output += util_execute("/sbin/chkconfig --del #{@model[:name]} 2>&1") + output = util_execute("#{command(:chkconfig)} #{@model[:name]} off 2>&1") + output += util_execute("#{command(:chkconfig)} --del #{@model[:name]} 2>&1") rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not disable %s: %s" % [self.name, output] @@ -21,11 +21,17 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do def enabled? begin - output = util_execute("/sbin/chkconfig #{@model[:name]} 2>&1").chomp + output = util_execute("#{command(:chkconfig)} #{@model[:name]} 2>&1").chomp rescue Puppet::ExecutionFailure return :false end + # If it's disabled on SuSE, then it will print output showing "off" + # at the end + if output =~ /.* off$/ + return :false + end + return :true end @@ -33,8 +39,8 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do # in the init scripts. def enable begin - output = util_execute("/sbin/chkconfig --add #{@model[:name]} 2>&1") - output += util_execute("/sbin/chkconfig #{@model[:name]} on 2>&1") + output = util_execute("#{command(:chkconfig)} --add #{@model[:name]} 2>&1") + output += util_execute("#{command(:chkconfig)} #{@model[:name]} on 2>&1") rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not enable %s: %s" % [self.name, output] |