Proper generation of Exim domainlists
authorAdam Chlipala <adamc@hcoop.net>
Mon, 19 Feb 2007 03:03:06 +0000 (03:03 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Mon, 19 Feb 2007 03:03:06 +0000 (03:03 +0000)
configDefault/exim.cfg
configDefault/exim.csg
scripts/domtool-publish
src/plugins/exim.sml
src/plugins/mailman.sml

index ac20501..a1ef37a 100644 (file)
@@ -3,6 +3,7 @@ structure Exim :> EXIM_CONFIG = struct
 val aliases = "/var/domtool/aliases"
 val aliasesDefault = "/var/domtool/aliases.default"
 val handleDomains = "/var/domtool/local_domains.cfg"
+val relayDomains = "/var/domtool/relay_domains.cfg"
 
 val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish exim"
 
index b76e4c5..e28dee3 100644 (file)
@@ -11,6 +11,9 @@ val reload : string
 val handleDomains : string
 (* File to which to write a comma-separate list of domains to handle mail for *)
 
+val relayDomains : string
+(* File to which to write a comma-separate list of domains to relay mail for *)
+
 val aliasTo : string list
 (* Default nodes to which alias directives are applied *)
 
index 6412a91..b84f1df 100755 (executable)
@@ -1,5 +1,18 @@
 #!/bin/sh -e
 
+redo_exim() {
+       /bin/echo -n "domainlist local_domains = " >/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/cat /var/domtool/local_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/echo -n "domainlist relay_to_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/cat /var/domtool/relay_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/echo -n "domainlist mm_domains = " >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/cat /var/domtool/mailman_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
+       /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
+       /etc/init.d/exim4 reload
+}
+
 case $1 in
        apache)
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
@@ -20,14 +33,12 @@ case $1 in
        exim)
                /bin/cp /var/domtool/aliases /etc/
                /bin/cp /var/domtool/aliases.default /etc/
-               /bin/echo -n "domainlist local_domains = " >/etc/exim4/conf.d/main/10_domtool-domains
-               /bin/cat /var/domtool/local_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
-               /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
-               /etc/init.d/exim4 reload
+               redo_exim
        ;;
        mailman)
                /bin/cp /var/domtool/mailman.map /etc/mailman
                /etc/init.d/mailman reload
+               redo_exim
        ;;
        courier)
                /bin/cat /etc/courier/userdb/* >/etc/courier/exim
index bb2743a..8b0485b 100644 (file)
@@ -31,6 +31,7 @@ val _ = Defaults.registerDefault ("MailNodes",
 val aliasesChanged = ref false
 val aliasesDefaultChanged = ref false
 val hostsChanged = ref false
+val relayHostsChanged = ref false
 
 val () = Slave.registerPreHandler
             (fn () => (aliasesChanged := false;
@@ -47,6 +48,8 @@ val () = Slave.registerFileHandler (fn fs =>
                                               aliasesDefaultChanged := true
                                           else if #file spl = "mail" then
                                               hostsChanged := true
+                                          else if #file spl = "mail.relay" then
+                                              relayHostsChanged := true
                                           else
                                               ()
                                       end)
@@ -65,8 +68,12 @@ val () = Slave.registerPostHandler
                  Slave.enumerateTo (fn s => s = "mail") ":" Config.Exim.handleDomains
              else
                  ();
+             if !relayHostsChanged then
+                 Slave.enumerateTo (fn s => s = "mail.relay") ":" Config.Exim.relayDomains
+             else
+                 ();
              if !aliasesChanged orelse !aliasesDefaultChanged
-                orelse !hostsChanged then
+                orelse !hostsChanged orelse !relayHostsChanged then
                  Slave.shellF ([Config.Exim.reload],
                                fn cl => "Error reloading exim with " ^ cl)
              else
@@ -83,4 +90,14 @@ val () = Env.actionV_none "handleMail"
                                                         name = "mail"})) nodes
             end)
 
+val () = Env.actionV_none "relayMail"
+        (fn env =>
+            let
+                val nodes = Env.env (Env.list Env.string) (env, "MailNodes")
+            in
+                app (fn node => TextIO.closeOut
+                                    (Domain.domainFile {node = node,
+                                                        name = "mail.relay"})) nodes
+            end)
+
 end
index 8cf9873..b8925a3 100644 (file)
@@ -55,7 +55,9 @@ val () = Slave.registerPostHandler (fn () =>
                                       if !mailmanChanged then
                                           (Slave.concatTo (fn s => s = "mailman")
                                                           Config.Mailman.mapFile;
-                                           Slave.shellF ([Config.Mailman.reload],
+                                           Slave.enumerateTo (fn s => s = "mailman") ":"
+                                                             Config.Mailman.handleDomains;
+                                                             Slave.shellF ([Config.Mailman.reload],
                                                       fn cl => "Error reloading Mailman with " ^ cl))
                                       else
                                           ())