1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006, Adam Chlipala
4 * This program is free software
; you can redistribute it
and/or
5 * modify it under the terms
of the GNU General Public License
6 * as published by the Free Software Foundation
; either version
2
7 * of the License
, or (at your option
) any later version
.
9 * This program is distributed
in the hope that it will be useful
,
10 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
12 * GNU General Public License for more details
.
14 * You should have received a copy
of the GNU General Public License
15 * along
with this program
; if not
, write to the Free Software
16 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
19 (* Exim MTA handling
*)
21 structure Exim
:> EXIM
= struct
25 val aliasesChanged
= ref
false
26 val aliasesDefaultChanged
= ref
false
27 val hostsChanged
= ref
false
28 val relayHostsChanged
= ref
false
30 val () = Slave
.registerPreHandler
31 (fn () => (aliasesChanged
:= false;
32 aliasesDefaultChanged
:= false;
33 hostsChanged
:= false))
35 val () = Slave
.registerFileHandler (fn fs
=>
37 val spl
= OS
.Path
.splitDirFile (#file fs
)
39 if #file spl
= "aliases.base" then
40 aliasesChanged
:= true
41 else if #file spl
= "aliases.default" then
42 aliasesDefaultChanged
:= true
43 else if #file spl
= "mail.handle" then
45 else if #file spl
= "mail.relay" then
46 relayHostsChanged
:= true
51 val () = Slave
.registerPostHandler
53 (if !aliasesChanged
then
54 Slave
.concatTo (fn s
=> s
= "aliases.base") Config
.Exim
.aliases
57 if !aliasesDefaultChanged
then
58 Slave
.concatTo (fn s
=> s
= "aliases.default") Config
.Exim
.aliasesDefault
62 Slave
.enumerateTo (fn s
=> s
= "mail.handle") ":" Config
.Exim
.handleDomains
65 if !relayHostsChanged
then
66 Slave
.enumerateTo (fn s
=> s
= "mail.relay") ":" Config
.Exim
.relayDomains
69 if !aliasesChanged
orelse !aliasesDefaultChanged
70 orelse !hostsChanged
orelse !relayHostsChanged
then
71 Slave
.shellF ([Config
.Exim
.reload
],
72 fn cl
=> "Error reloading exim with " ^ cl
)
77 val () = Env
.actionV_none
"handleMail"
80 val nodes
= Env
.env (Env
.list Env
.string) (env
, "MailNodes")
82 app (fn node
=> #close
83 (Domain
.domainsFile
{node
= node
,
84 name
= "mail.handle"}) ()) nodes
87 val () = Env
.actionV_none
"relayMail"
90 val nodes
= Env
.env (Env
.list Env
.string) (env
, "MailNodes")
92 app (fn node
=> #close
93 (Domain
.domainsFile
{node
= node
,
94 name
= "mail.relay"}) ()) nodes
97 val () = Domain
.registerDescriber (Domain
.considerAll
98 [Domain
.Filename
{filename
= "aliases.base",
99 heading
= "E-mail aliases:",
101 Domain
.Filename
{filename
= "aliases.default",
102 heading
= "Default e-mail alias:",
104 Domain
.Filename
{filename
= "mail.handle",
105 heading
= "E-mail handling is on.",
107 Domain
.Filename
{filename
= "mail.relay",
108 heading
= "E-mail relaying is on.",