X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/dee1a22babf7a1eb1c938f716dc37ced3abfd4e4..201b83c73c5a4e09dcf4c3f2f9b94ded360c78c6:/src/mail/vmail.sml diff --git a/src/mail/vmail.sml b/src/mail/vmail.sml index cf36f9f..48d2287 100644 --- a/src/mail/vmail.sml +++ b/src/mail/vmail.sml @@ -1,5 +1,5 @@ (* HCoop Domtool (http://hcoop.sourceforge.net/) - * Copyright (c) 2006, Adam Chlipala + * Copyright (c) 2006-2009, Adam Chlipala * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,7 +20,45 @@ structure Vmail :> VMAIL = struct -fun rebuild () = Slave.shell [Config.Courier.postReload] +open MsgTypes + +fun rebuild () = + let + fun doNode (site, ok) = + (print ("New vmail data for node " ^ site ^ "\n"); + if site = Config.dispatcherName then + Slave.shell [Config.Courier.postReload] andalso ok + else let + val bio = OpenSSL.connect true (Domain.get_context (), + Domain.nodeIp site + ^ ":" + ^ Int.toString Config.slavePort) + in + Msg.send (bio, MsgVmailChanged); + (case Msg.recv bio of + NONE => (print "Slave closed connection unexpectedly\n"; + false) + | SOME m => + case m of + MsgOk => (print ("Slave " ^ site ^ " finished\n"); + ok) + | MsgError s => (print ("Slave " ^ site + ^ " returned error: " ^ + s ^ "\n"); + false) + | _ => (print ("Slave " ^ site + ^ " returned unexpected command\n"); + false)) + before OpenSSL.close bio + end) + in + Slave.shell [Config.Courier.pushUserdb] + andalso foldl doNode true Config.mailNodes_all + end + +fun doChanged () = + Slave.shell [Config.Courier.pullUserdb] + andalso Slave.shell [Config.Courier.postReload] datatype listing = Error of string @@ -29,7 +67,7 @@ datatype listing = fun list domain = let val file = OS.Path.joinDirFile {dir = Config.Courier.userdbDir, - file = domain} + file = domain} in if Posix.FileSys.access (file, []) then let