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
23 val aliasesChanged
= ref
false
24 val aliasesDefaultChanged
= ref
false
25 val hostsChanged
= ref
false
27 val () = Slave
.registerPreHandler
28 (fn () => (aliasesChanged
:= false;
29 aliasesDefaultChanged
:= false;
30 hostsChanged
:= false))
32 val () = Slave
.registerFileHandler (fn fs
=>
34 val spl
= OS
.Path
.splitDirFile (#file fs
)
36 if #file spl
= "aliases" then
37 aliasesChanged
:= true
38 else if #file spl
= "aliases.default" then
39 aliasesDefaultChanged
:= true
40 else if #file spl
= "mail" then
46 val () = Slave
.registerPostHandler
48 (if !aliasesChanged
then
49 Slave
.concatTo (fn s
=> s
= "aliases") Config
.Exim
.aliases
52 if !aliasesDefaultChanged
then
53 Slave
.concatTo (fn s
=> s
= "aliases.default") Config
.Exim
.aliasesDefault
57 Slave
.enumerateTo (fn s
=> s
= "mail") ":" Config
.Exim
.handleDomains
60 if !aliasesChanged
orelse !aliasesDefaultChanged
61 orelse !hostsChanged
then
62 Slave
.shellF ([Config
.Exim
.reload
],
63 fn cl
=> "Error reloading exim with " ^ cl
)
68 val () = Env
.action_none
"handleMail"
69 (fn () => TextIO.closeOut (Domain
.domainFile
"mail"))