5 # Copyright 2011, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 include_recipe "networking"
28 package "exim4-daemon-heavy" if File.exist?("/var/run/clamav/clamd.ctl")
36 openssl_x509_certificate "/etc/ssl/certs/exim.pem" do
37 key_file "/etc/ssl/private/exim.key"
42 email "postmaster@openstreetmap.org"
43 common_name node[:fqdn]
48 action [:enable, :start]
49 supports :status => true, :restart => true, :reload => true
50 subscribes :restart, "execute[/etc/ssl/certs/exim.pem]"
53 relay_to_domains = node[:exim][:relay_to_domains]
55 node[:exim][:routes].each_value do |route|
56 relay_to_domains |= route[:domains] if route[:host]
59 relay_from_hosts = node[:exim][:relay_from_hosts]
61 if node[:exim][:smarthost_name]
62 search(:node, "exim_smarthost_via:#{node[:exim][:smarthost_name]}\\:*").each do |host|
63 relay_from_hosts |= host.ipaddresses(:role => :external)
67 file "/etc/exim4/blocked-senders" do
73 template "/etc/exim4/exim4.conf" do
74 source "exim4.conf.erb"
78 variables :relay_to_domains => relay_to_domains.sort,
79 :relay_from_hosts => relay_from_hosts.sort
80 notifies :restart, "service[exim4]"
83 search(:accounts, "*:*").each do |account|
85 details = node[:accounts][:users][name] || {}
87 if details[:status] && account["email"]
88 node.default[:exim][:aliases][name] = account["email"]
92 if node[:exim][:private_aliases]
93 aliases = data_bag_item("exim", "aliases")
95 aliases[node[:exim][:private_aliases]].each do |name, address|
96 node.default[:exim][:aliases][name] = address
100 template "/etc/aliases" do
107 remote_directory "/etc/exim4/noreply" do
113 files_group "Debian-exim"
118 munin_plugin "exim_mailqueue"
119 munin_plugin "exim_mailstats"
121 if node[:exim][:smarthost_name]
122 node[:exim][:daemon_smtp_ports].each do |port|
123 firewall_rule "accept-inbound-smtp-#{port}" do
133 node[:exim][:daemon_smtp_ports].each do |port|
134 firewall_rule "accept-inbound-smtp-#{port}" do
136 source "bm:mail.openstreetmap.org"
145 if node[:exim][:smarthost_via] # ~FC023
146 firewall_rule "deny-outbound-smtp" do