Class: Chef::Provider::Service::Debian

Inherits:
Init show all
Defined in:
lib/chef/provider/service/debian.rb

Instance Attribute Summary

Attributes inherited from Chef::Provider

#current_resource, #new_resource, #node

Instance Method Summary collapse

Methods inherited from Init

#initialize, #reload_service, #restart_service, #start_service, #stop_service

Methods inherited from Simple

#reload_service, #restart_service, #start_service, #stop_service

Methods inherited from Chef::Provider::Service

#action_disable, #action_enable, #action_reload, #action_restart, #action_start, #action_stop, #initialize, #reload_service, #restart_service, #start_service, #stop_service

Methods included from Mixin::Command

handle_command_failures, not_if, only_if, output_of_command, popen4, run_command, run_command_with_systems_locale

Methods inherited from Chef::Provider

#action_nothing, build_from_file, #initialize

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string

Methods included from Mixin::RecipeDefinitionDSLCore

#method_missing

Methods included from Mixin::Language

#data_bag, #data_bag_item, #platform?, #search, #value_for_platform

Constructor Details

This class inherits a constructor from Chef::Provider::Service::Init

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore

Instance Method Details

#disable_serviceObject



57
58
59
# File 'lib/chef/provider/service/debian.rb', line 57

def disable_service()
  run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
end

#enable_serviceObject



53
54
55
# File 'lib/chef/provider/service/debian.rb', line 53

def enable_service()
  run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults")
end

#load_current_resourceObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chef/provider/service/debian.rb', line 27

def load_current_resource
  super
  
  unless ::File.exists? "/usr/sbin/update-rc.d"
    raise Chef::Exceptions::Service, "/usr/sbin/update-rc.d does not exist!"
  end

  status = popen4("/usr/sbin/update-rc.d -n -f #{@current_resource.service_name} remove") do |pid, stdin, stdout, stderr|
    r = /etc\/rc[\dS].d\/S|not installed/i
    stdout.each_line do |line|
      if r.match(line)
        @current_resource.enabled true
        break
      else
        @current_resource.enabled false
      end
    end
  end  

  unless status.exitstatus == 0
    raise Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{@current_resource.service_name} failed - #{status.inspect}"
  end

  @current_resource        
end