--- /dev/null
+structure Webalizer :> WEBALIZER_CONFIG = struct
+
+val configDir = "/home/adamc/fake/webalizer"
+val outputDir = "/home/adamc/fake/webalizerOut"
+
+end
--- /dev/null
+structure Webalizer : WEBALIZER_CONFIG
--- /dev/null
+signature WEBALIZER_CONFIG = sig
+
+ val configDir : string
+ val outputDir : string
+
+end
plugins/apache.sig
plugins/apache.sml
+plugins/webalizer.sig
+plugins/webalizer.sml
+
order.sig
order.sml
signature APACHE = sig
+ val registerPre : ({nodes : string list, id : string, hostname : string} -> unit) -> unit
+ (* Register a callback for the beginning of a vhost block. *)
+
+ val registerPost : (unit -> unit) -> unit
+ (* Register a callback for the end of a vhost block. *)
+
+ val registerAliaser : (string -> unit) -> unit
+ (* Register a callback for an alternate hostname that is configured. *)
+
end
(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
^ " "
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) =>
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,
- fn () => (write "</VirtualHost>\n";
+ fn () => (!post ();
+ write "</VirtualHost>\n";
app TextIO.closeOut (!vhostFiles)))
val () = Env.container_one "location"
(fn host =>
(write "\tServerAlias ";
write host;
- write "\n"))
+ write "\n";
+ !aliaser host))
val authType = fn (EVar "basic", _) => SOME "basic"
| (EVar "digest", _) => SOME "digest"
--- /dev/null
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *)
+
+(* Webalizer statistics tool handling *)
+
+signature WEBALIZER = sig
+
+end
--- /dev/null
+(* HCoop Domtool (http://hcoop.sourceforge.net/)
+ * Copyright (c) 2006, Adam Chlipala
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *)
+
+(* Webalizer statistics tool handling *)
+
+structure Webalizer :> WEBALIZER = struct
+
+val files = ref ([] : TextIO.outstream list)
+val write = ref (fn _ : string => ())
+
+val () = Apache.registerPre
+ (fn {nodes, id, hostname} =>
+ let
+ val fds = map (fn node => Domain.domainFile {node = node,
+ name = id ^ ".wbl"}) nodes
+ in
+ files := fds;
+ write := (fn s => app (fn fd => TextIO.output (fd, s)) fds);
+ !write "LogFile\t";
+ !write Config.Apache.logDir;
+ !write "/";
+ !write hostname;
+ !write "/access.log\nOutputDir\t";
+ !write Config.Webalizer.outputDir;
+ !write "/";
+ !write id;
+ !write "\nHostname\t";
+ !write hostname;
+ !write "\nHideSite\t";
+ !write hostname;
+ !write "\nHideReferrer\t";
+ !write hostname;
+ !write "\n"
+ end)
+
+val () = Apache.registerPost
+ (fn () => app TextIO.closeOut (!files))
+
+val () = Apache.registerAliaser
+ (fn hostname =>
+ (!write "HideSite\t";
+ !write hostname;
+ !write "\nHideReferrer\t";
+ !write hostname;
+ !write "\n"))
+
+val () = Slave.registerFileHandler (fn fs =>
+ let
+ val spl = OS.Path.splitDirFile (#file fs)
+ in
+ case OS.Path.splitBaseExt (#file spl) of
+ {base, ext = SOME "wbl"} =>
+ (case #action fs of
+ Slave.Delete =>
+ (ignore (OS.Process.system (Config.rm
+ ^ " -f "
+ ^ Config.Webalizer.configDir
+ ^ "/"
+ ^ base
+ ^ ".conf"));
+ ignore (OS.Process.system (Config.rm
+ ^ " -rf "
+ ^ Config.Webalizer.outputDir
+ ^ "/"
+ ^ base)))
+ | _ =>
+ (ignore (OS.Process.system (Config.cp
+ ^ " "
+ ^ #file fs
+ ^ " "
+ ^ Config.Webalizer.configDir
+ ^ "/"
+ ^ base
+ ^ ".conf"));
+ let
+ val dir = Config.Webalizer.outputDir ^ "/" ^ base
+ in
+ if Posix.FileSys.access (dir, []) then
+ ()
+ else
+ Posix.FileSys.mkdir (dir, Posix.FileSys.S.flags
+ [Posix.FileSys.S.iroth,
+ Posix.FileSys.S.ixoth,
+ Posix.FileSys.S.irwxu,
+ Posix.FileSys.S.irgrp,
+ Posix.FileSys.S.iwgrp])
+ end))
+ | _ => ()
+ end)
+
+end