Signed-off-by: Nigel Kersten <nig...@google.com> --- lib/puppet/provider/service/launchd.rb | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index 891c96b..8bf3a9d 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -103,12 +103,23 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do def status # launchctl list <jobname> exits zero if the job is loaded - # and non-zero if it isn't. Simple way to check... + # and non-zero if it isn't. Simple way to check... but is only + # available on OS X 10.5 unfortunately, so we grab the whole list + # and check if our resource is included. The output formats differ + # between 10.4 and 10.5, thus the necessity for splitting begin - launchctl :list, resource[:name] - return :running + jobs = [] + output = launchctl :list + output.split("\n").each do |j| + jobs << j.split(/\s/).last + end + if jobs.include?(resource[:name]) + return :running + else + return :stopped + end rescue Puppet::ExecutionFailure - return :stopped + raise Puppet::Error.new("Unable to determine status of #{resource[:name]}") end end -- 1.5.3.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---