diff options
author | Nigel Kersten <nigelk@google.com> | 2009-08-14 13:35:24 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-08-18 08:31:01 +1000 |
commit | c1967bb8d2e98d53182ea15fb13ac68d7bff7d84 (patch) | |
tree | 8237a8dad9b31df5efb50ef521293296f332ebd6 /lib | |
parent | 7e0924737d817644402b1c3d2d5abb2cf006e76b (diff) | |
download | puppet-c1967bb8d2e98d53182ea15fb13ac68d7bff7d84.tar.gz puppet-c1967bb8d2e98d53182ea15fb13ac68d7bff7d84.tar.xz puppet-c1967bb8d2e98d53182ea15fb13ac68d7bff7d84.zip |
Fixes #2513. debian service provider now uses invoke-rc.d to determine enabled? status
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/provider/service/debian.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb index 8527ae036..7ddbd288b 100755 --- a/lib/puppet/provider/service/debian.rb +++ b/lib/puppet/provider/service/debian.rb @@ -4,11 +4,16 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do desc "Debian's form of ``init``-style management. The only difference is that this supports service enabling and disabling - via ``update-rc.d``. + via ``update-rc.d`` and determines enabled status via ``invoke-rc.d``. " - commands :update => "/usr/sbin/update-rc.d" + commands :update_rc => "/usr/sbin/update-rc.d" + # note this isn't being used as a command until + # http://projects.reductivelabs.com/issues/2538 + # is resolved. + commands :invoke_rc => "/usr/sbin/invoke-rc.d" + defaultfor :operatingsystem => [:debian, :ubuntu] def self.defpath @@ -17,16 +22,19 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do # Remove the symlinks def disable - update "-f", @resource[:name], "remove" - update @resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", "." + update_rc "-f", @resource[:name], "remove" + update_rc @resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", "." end def enabled? - output = update "-n", "-f", @resource[:name], "remove" - - # If it's enabled, then it will print output showing removal of - # links. - if output =~ /etc\/rc[\dS].d\/S|not installed/ + # TODO: Replace system() call when Puppet::Util.execute gives us a way + # to determine exit status. http://projects.reductivelabs.com/issues/2538 + system("/usr/sbin/invoke-rc.d", "--query", @resource[:name], "start") + + # 104 is the exit status when you query start an enabled service. + # 106 is the exit status when the policy layer supplies a fallback action + # See x-man-page://invoke-rc.d + if [104, 106].include?($?.exitstatus) return :true else return :false @@ -34,7 +42,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do end def enable - update "-f", @resource[:name], "remove" - update @resource[:name], "defaults" + update_rc "-f", @resource[:name], "remove" + update_rc @resource[:name], "defaults" end end |