def load_current_resource
@current_resource = Chef::Resource::Service.new(@new_resource.name)
@current_resource.service_name(@new_resource.service_name)
@rcd_script_found = true
@enabled_state_found = false
if ::File.exists?("/etc/rc.d/#{current_resource.service_name}")
@init_command = "/etc/rc.d/#{current_resource.service_name}"
elsif ::File.exists?("/usr/local/etc/rc.d/#{current_resource.service_name}")
@init_command = "/usr/local/etc/rc.d/#{current_resource.service_name}"
else
@rcd_script_found = false
return
end
Chef::Log.debug("#{@current_resource} found at #{@init_command}")
determine_current_status!
var_name = service_enable_variable_name
if ::File.exists?("/etc/rc.conf") && var_name
read_rc_conf.each do |line|
case line
when /#{Regexp.escape(var_name)}="(\w+)"/
@enabled_state_found = true
if $1 =~ /[Yy][Ee][Ss]/
@current_resource.enabled true
elsif $1 =~ /[Nn][Oo][Nn]?[Oo]?[Nn]?[Ee]?/
@current_resource.enabled false
end
end
end
end
unless @current_resource.enabled
Chef::Log.debug("#{@new_resource.name} enable/disable state unknown")
@current_resource.enabled false
end
@current_resource
end