Webalizer
[hcoop/domtool2.git] / src / plugins / apache.sml
index 1f61476..3550166 100644 (file)
@@ -182,11 +182,18 @@ val () = Slave.registerFileHandler (fn fs =>
                                               (vhostsChanged := true;
                                                case #action fs of
                                                    Slave.Delete =>
                                               (vhostsChanged := true;
                                                case #action fs of
                                                    Slave.Delete =>
-                                                   ignore (OS.Process.system (Config.rm
-                                                                              ^ " -rf "
-                                                                              ^ Config.Apache.confDir
-                                                                              ^ "/"
-                                                                              ^ #file spl))
+                                                   (ignore (OS.Process.system (Config.rm
+                                                                               ^ " -rf "
+                                                                               ^ Config.Apache.confDir
+                                                                               ^ "/"
+                                                                               ^ #file spl));
+                                                    ignore (OS.Process.system (Config.rm
+                                                                               ^ " -rf "
+                                                                               ^ Config.Apache.logDir
+                                                                               ^ "/"
+                                                                               ^ #base (OS.Path.splitBaseExt 
+                                                                                            (#file spl)))))
+                                                           
                                                  | _ =>
                                                    ignore (OS.Process.system (Config.cp
                                                                               ^ " "
                                                  | _ =>
                                                    ignore (OS.Process.system (Config.cp
                                                                               ^ " "
@@ -214,6 +221,30 @@ val rewriteEnabled = ref false
 val currentVhost = ref ""
 val currentVhostId = ref ""
 
 val currentVhost = ref ""
 val currentVhostId = ref ""
 
+val pre = ref (fn _ : {nodes : string list, id : string, hostname : string} => ())
+fun registerPre f =
+    let
+       val old = !pre
+    in
+       pre := (fn x => (old x; f x))
+    end
+
+val post = ref (fn () => ())
+fun registerPost f =
+    let
+       val old = !post
+    in
+       post := (fn () => (old (); f ()))
+    end
+
+val aliaser = ref (fn _ : string => ())
+fun registerAliaser f =
+    let
+       val old = !aliaser
+    in
+       aliaser := (fn x => (old x; f x))
+    end
+
 val () = Env.containerV_one "vhost"
         ("host", Env.string)
         (fn (env, host) =>
 val () = Env.containerV_one "vhost"
         ("host", Env.string)
         (fn (env, host) =>
@@ -268,9 +299,11 @@ val () = Env.containerV_one "vhost"
                 write Config.Apache.logDir;
                 write "/";
                 write vhostId;
                 write Config.Apache.logDir;
                 write "/";
                 write vhostId;
-                write "/access.log combined\n"
+                write "/access.log combined\n";
+                !pre {nodes = nodes, id = vhostId, hostname = fullHost}
             end,
             end,
-         fn () => (write "</VirtualHost>\n";
+         fn () => (!post ();
+                   write "</VirtualHost>\n";
                    app TextIO.closeOut (!vhostFiles)))
 
 val () = Env.container_one "location"
                    app TextIO.closeOut (!vhostFiles)))
 
 val () = Env.container_one "location"
@@ -438,7 +471,8 @@ val () = Env.action_one "serverAlias"
         (fn host =>
             (write "\tServerAlias ";
              write host;
         (fn host =>
             (write "\tServerAlias ";
              write host;
-             write "\n"))
+             write "\n";
+             !aliaser host))
 
 val authType = fn (EVar "basic", _) => SOME "basic"
                | (EVar "digest", _) => SOME "digest"
 
 val authType = fn (EVar "basic", _) => SOME "basic"
                | (EVar "digest", _) => SOME "digest"