# class Chef::Provider::Service::Init

### Public Class Methods

new(new_resource, run_context) click to toggle source
Calls superclass method Chef::Provider::Service.new

    # File lib/chef/provider/service/init.rb, line 31
    def initialize(new_resource, run_context)
      super
      @init_command = "/etc/init.d/#{@new_resource.service_name}"
    end

### Public Instance Methods

define_resource_requirements() click to toggle source

    # File lib/chef/provider/service/init.rb, line 36
    def define_resource_requirements
      # do not call super here, inherit only shared_requirements
      shared_resource_requirements
      requirements.assert(:start, :stop, :restart, :reload) do |a|
        a.assertion do
          custom_command_for_action?(action) || ::File.exist?(default_init_command)
        end
        a.failure_message(Chef::Exceptions::Service, "#{default_init_command} does not exist!")
        a.whyrun("Init script '#{default_init_command}' doesn't exist, assuming a prior action would have created it.") do
          # blindly assume that the service exists but is stopped in why run mode:
          @status_load_success = false
        end
      end
    end

reload_service() click to toggle source
Calls superclass method Chef::Provider::Service::Simple#reload_service

    # File lib/chef/provider/service/init.rb, line 79
    def reload_service
      if @new_resource.reload_command
        super
      elsif @new_resource.supports[:reload]
        shell_out!("#{default_init_command} reload")
      end
    end

restart_service() click to toggle source
Calls superclass method Chef::Provider::Service::Simple#restart_service

    # File lib/chef/provider/service/init.rb, line 67
    def restart_service
      if @new_resource.restart_command
        super
      elsif @new_resource.supports[:restart]
        shell_out!("#{default_init_command} restart")
      else
        stop_service
        sleep 1
        start_service
      end
    end

start_service() click to toggle source
Calls superclass method Chef::Provider::Service::Simple#start_service

    # File lib/chef/provider/service/init.rb, line 51
    def start_service
      if @new_resource.start_command
        super
      else
        shell_out!("#{default_init_command} start")
      end
    end

stop_service() click to toggle source
Calls superclass method Chef::Provider::Service::Simple#stop_service

    # File lib/chef/provider/service/init.rb, line 59
    def stop_service
      if @new_resource.stop_command
        super
      else
        shell_out!("#{default_init_command} stop")
      end
    end