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 dl
= ErrorMsg
.dummyLoc
27 val _
= Defaults
.registerDefault ("MailNodes",
28 (TList (TBase
"mail_node", dl
), dl
),
29 (fn () => (EList (map (fn s
=> (EString s
, dl
)) Config
.Exim
.aliasTo
), dl
)))
31 val aliasesChanged
= ref
false
32 val aliasesDefaultChanged
= ref
false
33 val hostsChanged
= ref
false
35 val () = Slave
.registerPreHandler
36 (fn () => (aliasesChanged
:= false;
37 aliasesDefaultChanged
:= false;
38 hostsChanged
:= false))
40 val () = Slave
.registerFileHandler (fn fs
=>
42 val spl
= OS
.Path
.splitDirFile (#file fs
)
44 if #file spl
= "aliases" then
45 aliasesChanged
:= true
46 else if #file spl
= "aliases.default" then
47 aliasesDefaultChanged
:= true
48 else if #file spl
= "mail" then
54 val () = Slave
.registerPostHandler
56 (if !aliasesChanged
then
57 Slave
.concatTo (fn s
=> s
= "aliases") Config
.Exim
.aliases
60 if !aliasesDefaultChanged
then
61 Slave
.concatTo (fn s
=> s
= "aliases.default") Config
.Exim
.aliasesDefault
65 Slave
.enumerateTo (fn s
=> s
= "mail") ":" Config
.Exim
.handleDomains
68 if !aliasesChanged
orelse !aliasesDefaultChanged
69 orelse !hostsChanged
then
70 Slave
.shellF ([Config
.Exim
.reload
],
71 fn cl
=> "Error reloading exim with " ^ cl
)
76 val () = Env
.actionV_none
"handleMail"
79 val nodes
= Env
.env (Env
.list Env
.string) (env
, "MailNodes")
81 app (fn node
=> TextIO.closeOut
82 (Domain
.domainFile
{node
= node
,
83 name
= "mail"})) nodes