include_recipe 'snort::default'

# TODO: build a Pull Request for community cookbook,
# to allow more flexibility on configuration and avoid
# the rewind logic below
# Also submit oinkmaster configuration

# Download snort RPM from custom URL
snort_url = node['snort']['snort_url']
if snort_url
  snort_checksum = node['snort']['snort_checksum']
  snort_rpm = node['snort']['snort_rpm_name']
  r = resources(remote_file: "#{Chef::Config[:file_cache_path]}/#{snort_rpm}")
  r.source(snort_url)
  r.checksum(snort_checksum)
end

# Download DAQ RPM from custom URL
daq_url = node['snort']['daq_url']
if daq_url
  daq_checksum = node['snort']['daq_checksum']
  daq_rpm = node['snort']['daq_rpm_name']
  r = resources(remote_file: "#{Chef::Config[:file_cache_path]}/#{daq_rpm}")
  r.source(daq_url)
  r.checksum(daq_checksum)
end

directory '/etc/snort/rules' do
  action :create
  recursive true
end
