Domain alias support for Exim
[hcoop/domtool2.git] / src / plugins / mailman.sml
... / ...
CommitLineData
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(* Mailman mailing list handling *)
20
21structure Mailman :> MAILMAN = struct
22
23val files = ref ([] : TextIO.outstream list)
24val write = ref (fn _ : string => ())
25
26val () = Env.action_one "mailmanWebHost"
27 ("hostname", Env.string)
28 (fn host =>
29 let
30 val outf = Domain.domainFile {node = Config.Mailman.node,
31 name = "mailman"}
32 in
33 TextIO.output (outf, "\t'");
34 TextIO.output (outf, host);
35 TextIO.output (outf, "' : '");
36 TextIO.output (outf, Domain.currentDomain ());
37 TextIO.output (outf, "',\n");
38 TextIO.closeOut outf
39 end)
40
41val mailmanChanged = ref false
42
43val () = Slave.registerPreHandler (fn () => mailmanChanged := false)
44
45val () = Slave.registerFileHandler (fn fs =>
46 let
47 val spl = OS.Path.splitDirFile (#file fs)
48 in
49 case #file spl of
50 "mailman" => mailmanChanged := true
51 | _ => ()
52 end)
53
54val () = Slave.registerPostHandler (fn () =>
55 if !mailmanChanged then
56 (Slave.concatTo (fn s => s = "mailman")
57 Config.Mailman.mapFile;
58 Slave.enumerateTo (fn s => s = "mailman") ":"
59 Config.Mailman.handleDomains;
60 Slave.shellF ([Config.Mailman.reload],
61 fn cl => "Error reloading Mailman with " ^ cl))
62 else
63 ())
64
65end