Slaves and Exim
[hcoop/domtool2.git] / src / domain.sml
index 394bf80..534e440 100644 (file)
@@ -103,18 +103,6 @@ datatype file_action' =
        | Delete' of string
        | Modify' of {src : string, dst : string}
 
-fun shell ss = OS.Process.isSuccess (OS.Process.system (String.concat ss))
-
-fun shellF (ss, msg) =
-    let
-       val s = String.concat ss
-    in
-       if OS.Process.isSuccess (OS.Process.system s) then
-           ()
-       else
-           ErrorMsg.error NONE (msg s)
-    end
-
 fun findDiffs dom =
     let
        val realPath = getPath dom Config.resultRoot
@@ -136,7 +124,7 @@ fun findDiffs dom =
                    if Posix.FileSys.ST.isDir (Posix.FileSys.stat real) then
                        loopReal acts
                    else if Posix.FileSys.access (tmp, []) then
-                       if shell [Config.diff, " ", real, " ",  tmp] then
+                       if Slave.shell [Config.diff, " ", real, " ",  tmp] then
                            loopReal acts
                        else
                            loopReal (Modify' {src = tmp, dst = real} :: acts)
@@ -146,7 +134,7 @@ fun findDiffs dom =
 
        val acts = loopReal []
 
-       val dir = Posix.FileSys.opendir realPath
+       val dir = Posix.FileSys.opendir tmpPath
 
        fun loopTmp acts =
            case Posix.FileSys.readdir dir of
@@ -190,7 +178,7 @@ val _ = Env.container_one "domain"
                                  val diffs = findDiffs dom
 
                                  val diffs = map (fn Add' {src, dst} =>
-                                                     (shellF ([Config.cp, " ", src, " ", dst],
+                                                     (Slave.shellF ([Config.cp, " ", src, " ", dst],
                                                              fn cl => "Copy failed: " ^ cl);
                                                       {action = Slave.Add,
                                                        domain = dom,
@@ -203,7 +191,7 @@ val _ = Env.container_one "domain"
                                                        domain = dom,
                                                        file = dst})
                                                    | Modify' {src, dst} =>
-                                                     (shellF ([Config.cp, " ", src, " ", dst],
+                                                     (Slave.shellF ([Config.cp, " ", src, " ", dst],
                                                           fn cl => "Copy failed: " ^ cl);
                                                       {action = Slave.Modify,
                                                        domain = dom,
@@ -213,7 +201,7 @@ val _ = Env.container_one "domain"
                                      ()
                                  else
                                      Slave.handleChanges diffs;
-                                 ignore (shellF ([Config.rm, " -rf ", Config.tmpDir, "/*"],
+                                 ignore (Slave.shellF ([Config.rm, " -rf ", Config.tmpDir, "/*"],
                                                  fn cl => "Temp file cleanup failed: " ^ cl))
                              end)