diff options
author | Markus Roberts <Markus@reality.com> | 2009-09-03 17:43:24 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-05 09:24:28 +1000 |
commit | aba2f6600062c6935b65ebc2eeae0802e1f89a89 (patch) | |
tree | 252ed15abd6fddf7b6ec0e8d50d9b782c827b9f1 /lib/puppet/provider/service/init.rb | |
parent | fb236a00459c375e4f2a94bdd924ed4e7fbd25eb (diff) | |
download | puppet-aba2f6600062c6935b65ebc2eeae0802e1f89a89.tar.gz puppet-aba2f6600062c6935b65ebc2eeae0802e1f89a89.tar.xz puppet-aba2f6600062c6935b65ebc2eeae0802e1f89a89.zip |
This further normalizes the handling of init-style services (including
the redhat "service" wrapper script). Removes special case handling of
non-zero exit code in redhat (base already did this) and centralizes
scattered @resource[:has_____] checks. Tests that proper versions of
each are called and one level of fallbacks.
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib/puppet/provider/service/init.rb')
-rwxr-xr-x | lib/puppet/provider/service/init.rb | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index 1bf11fbba..965773d96 100755 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -67,20 +67,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do # Where is our init script? def initscript - if defined? @initscript - return @initscript - else - @initscript = self.search(@resource[:name]) - end - end - - def restart - if @resource[:hasrestart] == :true - command = [self.initscript, :restart] - texecute("restart", command) - else - super - end + @initscript ||= self.search(@resource[:name]) end def search(name) @@ -115,23 +102,24 @@ Puppet::Type.type(:service).provide :init, :parent => :base do # The start command is just the init scriptwith 'start'. def startcmd - [self.initscript, :start] + [initscript, :start] + end + + # The stop command is just the init script with 'stop'. + def stopcmd + [initscript, :stop] + end + + def restartcmd + (@resource[:hasrestart] == :true) && [initscript, :restart] end # If it was specified that the init script has a 'status' command, then # we just return that; otherwise, we return false, which causes it to # fallback to other mechanisms. def statuscmd - if @resource[:hasstatus] == :true - return [self.initscript, :status] - else - return false - end + (@resource[:hasstatus] == :true) && [initscript, :status] end - # The stop command is just the init script with 'stop'. - def stopcmd - [self.initscript, :stop] - end end |