Mailman and Bind fixes
authorAdam Chlipala <adamc@hcoop.net>
Sun, 27 Aug 2006 03:17:14 +0000 (03:17 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sun, 27 Aug 2006 03:17:14 +0000 (03:17 +0000)
12 files changed:
configDefault/mailman.cfg [new file with mode: 0644]
configDefault/mailman.cfs [new file with mode: 0644]
configDefault/mailman.csg [new file with mode: 0644]
lib/domain.dtl
lib/mailman.dtl [new file with mode: 0644]
src/domain.sml
src/domtool.cm
src/plugins/bind.sml
src/plugins/mailman.sig [new file with mode: 0644]
src/plugins/mailman.sml [new file with mode: 0644]
tests/testBind.dtl
tests/testMailman.dtl [new file with mode: 0644]

diff --git a/configDefault/mailman.cfg b/configDefault/mailman.cfg
new file mode 100644 (file)
index 0000000..ab6f51a
--- /dev/null
@@ -0,0 +1,10 @@
+structure Mailman :> MAILMAN_CONFIG = struct
+
+val node = "this"
+
+val mapFile = "/home/adamc/fake/mailman.map"
+
+val reload = "echo \"I would reload Mailman now.\""
+(* "/etc/init.d/mailman reload" *)
+
+end
diff --git a/configDefault/mailman.cfs b/configDefault/mailman.cfs
new file mode 100644 (file)
index 0000000..7c1623d
--- /dev/null
@@ -0,0 +1 @@
+structure Mailman : MAILMAN_CONFIG
diff --git a/configDefault/mailman.csg b/configDefault/mailman.csg
new file mode 100644 (file)
index 0000000..19eadb4
--- /dev/null
@@ -0,0 +1,9 @@
+signature MAILMAN_CONFIG = sig
+
+    val node : string
+
+    val mapFile : string
+
+    val reload : string
+
+end
index 69b0f5e..f2d3150 100644 (file)
@@ -51,6 +51,8 @@ extern type soa;
 {{DNS start-of-authority record}}
 extern val soa : domain -> serial -> int -> int -> int -> int -> soa;
 
 {{DNS start-of-authority record}}
 extern val soa : domain -> serial -> int -> int -> int -> int -> soa;
 
+val defaultSoa = soa "ns.hcoop.net" serialAuto 172800 900 1209600 3600;
+
 extern type master;
 {{Information on the master DNS server for a domain}}
 extern val externalMaster : ip -> master;
 extern type master;
 {{Information on the master DNS server for a domain}}
 extern val externalMaster : ip -> master;
diff --git a/lib/mailman.dtl b/lib/mailman.dtl
new file mode 100644 (file)
index 0000000..2cf0445
--- /dev/null
@@ -0,0 +1,5 @@
+{{Mailman mailing list system}}
+
+extern val mailmanWebHost : domain -> [Domain];
+{{Set the hostname of the web site for administration of mailing lists for this
+  domain.}}
index 55531d8..da18f22 100644 (file)
@@ -222,6 +222,7 @@ val dnsKind = fn (EApp ((EApp ((EApp
                                    master = mstr,
                                    slaves = slaves})
                    | _ => NONE)
                                    master = mstr,
                                    slaves = slaves})
                    | _ => NONE)
+              | (EVar "noDns", _) => SOME NoDns
               | _ => NONE
 
 val befores = ref (fn (_ : string) => ())
               | _ => NONE
 
 val befores = ref (fn (_ : string) => ())
index 1210624..ff07373 100644 (file)
@@ -65,6 +65,9 @@ plugins/apache.sml
 plugins/webalizer.sig
 plugins/webalizer.sml
 
 plugins/webalizer.sig
 plugins/webalizer.sml
 
+plugins/mailman.sig
+plugins/mailman.sml
+
 order.sig
 order.sml
 
 order.sig
 order.sml
 
index 4b09b45..faa8e4e 100644 (file)
@@ -39,7 +39,8 @@ val _ = Domain.registerBefore
                                       (Domain.dnsMaster ()))
        
 val _ = Domain.registerAfter
                                       (Domain.dnsMaster ()))
        
 val _ = Domain.registerAfter
-           (fn _ => Option.app TextIO.closeOut (!dns))
+           (fn _ => (Option.app TextIO.closeOut (!dns);
+                     dns := NONE))
 
 val dl = ErrorMsg.dummyLoc
 
 
 val dl = ErrorMsg.dummyLoc
 
@@ -129,7 +130,8 @@ val () = Slave.registerFileHandler (fn fs =>
                                                       val fname = OS.Path.joinDirFile {dir = Config.Bind.zonePath,
                                                                                        file = fname}
                                                   in
                                                       val fname = OS.Path.joinDirFile {dir = Config.Bind.zonePath,
                                                                                        file = fname}
                                                   in
-                                                      OS.FileSys.remove fname
+                                                      Slave.shellF ([Config.rm, " -f ", fname],
+                                                                 fn cl => "Error deleting file: " ^ cl)
                                                   end
                                               else
                                                   let
                                                   end
                                               else
                                                   let
@@ -176,8 +178,11 @@ val () = Slave.registerFileHandler (fn fs =>
                                                       TextIO.output (outf, Int.toString min);
                                                       TextIO.output (outf, " )\n\n");
                                                       TextIO.closeOut outf;
                                                       TextIO.output (outf, Int.toString min);
                                                       TextIO.output (outf, " )\n\n");
                                                       TextIO.closeOut outf;
-                                                      Slave.shellF ([Config.cat, " ", dns, " >>", fname],
-                                                                 fn cl => "Error concatenating file: " ^ cl);
+                                                      if Posix.FileSys.access (dns, []) then
+                                                          Slave.shellF ([Config.cat, " ", dns, " >>", fname],
+                                                                     fn cl => "Error concatenating file: " ^ cl)
+                                                      else
+                                                          ();
                                                       didDomain := #domain fs
                                                   end
                                       in
                                                       didDomain := #domain fs
                                                   end
                                       in
diff --git a/src/plugins/mailman.sig b/src/plugins/mailman.sig
new file mode 100644 (file)
index 0000000..c974c3d
--- /dev/null
@@ -0,0 +1,23 @@
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *)
+
+(* Mailman mailing list handling *)
+
+signature MAILMAN = sig
+
+end
diff --git a/src/plugins/mailman.sml b/src/plugins/mailman.sml
new file mode 100644 (file)
index 0000000..8cf9873
--- /dev/null
@@ -0,0 +1,63 @@
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *)
+
+(* Mailman mailing list handling *)
+
+structure Mailman :> MAILMAN = struct
+
+val files = ref ([] : TextIO.outstream list)
+val write = ref (fn _ : string => ())
+
+val () = Env.action_one "mailmanWebHost"
+                       ("hostname", Env.string)
+                       (fn host =>
+                           let
+                               val outf = Domain.domainFile {node = Config.Mailman.node,
+                                                             name = "mailman"}
+                           in
+                               TextIO.output (outf, "\t'");
+                               TextIO.output (outf, host);
+                               TextIO.output (outf, "' : '");
+                               TextIO.output (outf, Domain.currentDomain ());
+                               TextIO.output (outf, "',\n");
+                               TextIO.closeOut outf
+                           end)
+
+val mailmanChanged = ref false
+
+val () = Slave.registerPreHandler (fn () => mailmanChanged := false)
+
+val () = Slave.registerFileHandler (fn fs =>
+                                      let
+                                          val spl = OS.Path.splitDirFile (#file fs)
+                                      in
+                                          case #file spl of
+                                              "mailman" => mailmanChanged := true
+                                            | _ => ()
+                                      end)
+
+val () = Slave.registerPostHandler (fn () =>
+                                      if !mailmanChanged then
+                                          (Slave.concatTo (fn s => s = "mailman")
+                                                          Config.Mailman.mapFile;
+                                           Slave.shellF ([Config.Mailman.reload],
+                                                      fn cl => "Error reloading Mailman with " ^ cl))
+                                      else
+                                          ())
+
+end
index 8dc781b..f88c624 100644 (file)
@@ -7,16 +7,21 @@ domain "hcoop.net" with
 
 end;
 
 
 end;
 
-domain "tpu.org" with
-
-       dns (dnsNS "my.nso");
-       dns (dnsMX 14 "mail.nowhere.eu");
+domain "tpu.org" where
+       TTL = 75;
+       DNS = useDns defaultSoa (externalMaster "66.66.66.66") ["this"]
+with
 
 end;
 
 
 end;
 
-domain "schizomaniac.net" with
-
-       dns (dnsCNAME "a" "b.com");
+domain "schizomaniac.net" where
+       DNS = noDns
+with
 
 end;
 
 
 end;
 
+domain "hprog.org" where
+       DNS = useDns defaultSoa (internalMaster "this") ["this"]
+with
+
+end;
diff --git a/tests/testMailman.dtl b/tests/testMailman.dtl
new file mode 100644 (file)
index 0000000..4744022
--- /dev/null
@@ -0,0 +1,11 @@
+domain "hcoop.net" with
+       mailmanWebHost "lists.hcoop.net"
+end;
+
+domain "schizomaniac.net" with
+
+end;
+
+domain "tpu.org" with
+       mailmanWebHost "jamboree.hprog.org"
+end