Slaves and Exim
[hcoop/domtool2.git] / src / plugins / exim.sml
CommitLineData
8df2e702
AC
1(* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
3 *
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.
8 *
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.
13 *
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.
17 *)
18
19(* Exim MTA handling *)
20
21structure Exim :> EXIM = struct
22
23val aliasesChanged = ref false
24val aliasesDefaultChanged = ref false
25
26val () = Slave.registerPreHandler
27 (fn () => (aliasesChanged := false;
28 aliasesDefaultChanged := false))
29
30val () = Slave.registerFileHandler (fn fs =>
31 let
32 val spl = OS.Path.splitDirFile (#file fs)
33 in
34 if #file spl = "aliases" then
35 aliasesChanged := true
36 else if #file spl = "aliases.default" then
37 aliasesDefaultChanged := true
38 else
39 ()
40 end)
41
42val () = Slave.registerPostHandler
43 (fn () =>
44 (if !aliasesChanged then
45 Slave.concatTo (fn s => s = "aliases") Config.Exim.aliases
46 else
47 ();
48 if !aliasesDefaultChanged then
49 Slave.concatTo (fn s => s = "aliases.default") Config.Exim.aliasesDefault
50 else
51 ();
52 if !aliasesChanged orelse !aliasesDefaultChanged then
53 Slave.shellF ([Config.Exim.reload],
54 fn cl => "Error reloading exim with " ^ cl)
55 else
56 ()))
57
58end