def load_current_resource
@current_resource = Chef::Resource::Mount.new(@new_resource.name)
@current_resource.mount_point(@new_resource.mount_point)
@current_resource.device(@new_resource.device)
Chef::Log.debug("Checking for mount point #{@current_resource.mount_point}")
if (device_should_exist? && !::File.exists?(device_real) )
raise Chef::Exceptions::Mount, "Device #{@new_resource.device} does not exist"
elsif( !::File.exists?(@new_resource.mount_point) )
raise Chef::Exceptions::Mount, "Mount point #{@new_resource.mount_point} does not exist"
end
mounted = false
shell_out!("mount").stdout.each_line do |line|
case line
when /^#{device_mount_regex}\s+on\s+#{Regexp.escape(@new_resource.mount_point)}/
mounted = true
Chef::Log.debug("Special device #{device_logstring} mounted as #{@new_resource.mount_point}")
when /^([\/\w])+\son\s#{Regexp.escape(@new_resource.mount_point)}\s+/
mounted = false
Chef::Log.debug("Special device #{$~[1]} mounted as #{@new_resource.mount_point}")
end
end
@current_resource.mounted(mounted)
enabled = false
::File.foreach("/etc/fstab") do |line|
case line
when /^[#\s]/
next
when /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
enabled = true
@current_resource.fstype($1)
@current_resource.options($2)
@current_resource.dump($3.to_i)
@current_resource.pass($4.to_i)
Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/fstab")
when /^[\/\w]+\s+#{Regexp.escape(@new_resource.mount_point)}/
enabled = false
Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/fstab")
end
end
@current_resource.enabled(enabled)
end