ip_of_node support
[hcoop/domtool2.git] / src / plugins / bind.sml
index 4b09b45..8dc1a72 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
 
@@ -50,7 +51,7 @@ datatype dns_record =
        | NS of string
 
 val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) =>
        | NS of string
 
 val record = fn (EApp ((EApp ((EVar "dnsA", _), e1), _), e2), _) =>
-               (case (Env.string e1, Env.string e2) of
+               (case (Env.string e1, Domain.ip e2) of
                     (SOME v1, SOME v2) => SOME (A (v1, v2))
                   | _ => NONE)
              | (EApp ((EApp ((EVar "dnsCNAME", _), e1), _), e2), _) =>
                     (SOME v1, SOME v2) => SOME (A (v1, v2))
                   | _ => NONE)
              | (EApp ((EApp ((EVar "dnsCNAME", _), e1), _), e2), _) =>
@@ -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