+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]