Add MySQL skeleton
[hcoop/domtool2.git] / src / plugins / bind.sml
index 9a05dce..9c72152 100644 (file)
@@ -131,7 +131,7 @@ val monthToInt = fn Date.Jan => 1
 
 fun padBy ch amt s =
     if size s < amt then
-       CharVector.tabulate (amt, fn _ => ch) ^ s
+       CharVector.tabulate (amt - size s, fn _ => ch) ^ s
     else
        s
 
@@ -177,13 +177,15 @@ val () = Slave.registerFileHandler (fn fs =>
                                                       val min = readILine inf
                                                       val () = TextIO.closeIn inf
 
+                                                      val serialPath = OS.Path.joinDirFile {dir = Config.serialDir,
+                                                                                            file = #domain fs}
+
                                                       val oldSerial = let
-                                                          val inf = TextIO.openIn (OS.Path.joinDirFile {dir = #dir fs,
-                                                                                                        file = "serial"})
+                                                          val inf = TextIO.openIn serialPath
                                                       in
                                                           SOME (readLine inf)
                                                           before TextIO.closeIn inf
-                                                      end handle IO.Io _ => NONE
+                                                      end handle IO.Io {name, ...} => NONE
 
                                                       val newSerial =
                                                           case serial of
@@ -205,8 +207,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                                                              "00")
                                                               end
 
-                                                      val outf = TextIO.openOut (OS.Path.joinDirFile {dir = #dir fs,
-                                                                                                      file = "serial"})
+                                                      val outf = TextIO.openOut serialPath
                                                       val _ = TextIO.output (outf, newSerial)
                                                       val _ = TextIO.closeOut outf
 
@@ -265,4 +266,8 @@ val () = Slave.registerPostHandler
                                 fn cl => "Error reloading bind with " ^ cl)
                  else
                      ()))
+
+val () = Domain.registerResetLocal (fn () =>
+                                      ignore (OS.Process.system (Config.rm ^ " -rf /var/domtool/zones/*")))
+
 end