<commit_before>#
# Cookbook Name:: monit
# Recipe:: source
#

source = node['monit']['source']

include_recipe 'apt' if platform_family?('debian')
include_recipe 'build-essential'

build_deps = value_for_platform(
  %w{centos redhat fedora scientific} => {
    'default' => %w{pam-devel openssl-devel},
  },
  'default' => %w{libpam0g-dev libssl-dev},
)

build_deps.each do |build_dep|
  package build_dep
end

monit_bin = "#{source['prefix']}/bin/monit"

source_url = "#{source['url']}/monit-#{source['version']}.tar.gz"

download_path = Chef::Config['file_cache_path'] || '/tmp'

source_file_path = "#{download_path}/monit-#{source['version']}.tar.gz"

build_root = "#{download_path}/monit-#{source['version']}"

opts = "--prefix=#{source['prefix']}"

if platform_family?('debian') && source['version'].to_f < 5.6
  opts += " --with-ssl-lib-dir=/usr/lib/#{node['kernel']['machine']}-linux-gnu"
end

remote_file source_file_path do
  source source_url
  checksum source['checksum']
  path source_file_path
  backup false
  notifies :run, 'execute[extract-source-archive]', :immediately
end

execute 'extract-source-archive' do
  cwd download_path
  command <<-EOC
    tar xzf #{::File.basename(source_file_path)} -C #{download_path}
  EOC
  action :nothing
  notifies :run, 'execute[compile-source]', :immediately
end

execute 'compile-source' do
  cwd build_root
  command <<-EOC
    ./configure #{opts} && make && make install
  EOC
  action :nothing
end

template '/etc/init.d/monit' do
  source 'monit.init.erb'
  owner  'root'
  group  'root'
  mode   '0755'
  variables(
    :platform_family => node['platform_family'],
    :binary          => monit_bin,
    :conf_file       => node['monit']['conf_file'],
  )
end<commit_msg>link upstream default config path to platform default<commit_after>#
# Cookbook Name:: monit
# Recipe:: source
#

source = node['monit']['source']

include_recipe 'apt' if platform_family?('debian')
include_recipe 'build-essential'

build_deps = value_for_platform(
  %w{centos redhat fedora scientific} => {
    'default' => %w{pam-devel openssl-devel},
  },
  'default' => %w{libpam0g-dev libssl-dev},
)

build_deps.each do |build_dep|
  package build_dep
end

monit_bin = "#{source['prefix']}/bin/monit"

source_url = "#{source['url']}/monit-#{source['version']}.tar.gz"

download_path = Chef::Config['file_cache_path'] || '/tmp'

source_file_path = "#{download_path}/monit-#{source['version']}.tar.gz"

build_root = "#{download_path}/monit-#{source['version']}"

opts = "--prefix=#{source['prefix']}"

if platform_family?('debian') && source['version'].to_f < 5.6
  opts += " --with-ssl-lib-dir=/usr/lib/#{node['kernel']['machine']}-linux-gnu"
end

remote_file source_file_path do
  source source_url
  checksum source['checksum']
  path source_file_path
  backup false
  notifies :run, 'execute[extract-source-archive]', :immediately
end

execute 'extract-source-archive' do
  cwd download_path
  command <<-EOC
    tar xzf #{::File.basename(source_file_path)} -C #{download_path}
  EOC
  action :nothing
  notifies :run, 'execute[compile-source]', :immediately
end

execute 'compile-source' do
  cwd build_root
  command <<-EOC
    ./configure #{opts} && make && make install
  EOC
  action :nothing
end

# this is the upstream default config
# path. we link it to the platform
# default rather than patching the source,
# which would require carrying multiple
# patches for different versions; this
# also allows calling monit without passing
# the path to the global config file as an argument
link '/etc/monitrc' do
  to "#{node['monit']['conf_file']}"
  not_if { "#{node['monit']['conf_file']}" == '/etc/monitrc' }
end

template '/etc/init.d/monit' do
  source 'monit.init.erb'
  owner  'root'
  group  'root'
  mode   '0755'
  variables(
    :platform_family => node['platform_family'],
    :binary          => monit_bin,
    :conf_file       => node['monit']['conf_file'],
  )
end
{'fraction_non_alphanumeric': 0.16254777070063695, 'fraction_numerical': 0.0035668789808917197, 'mean_word_length': 4.6085714285714285, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5855126', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1378, 'n_words': 306}