src/domtool.cm: Makefile src/prefix.cm src/sources
cat src/prefix.cm src/sources >src/domtool.cm
+MAKE_MLB_BASE := cat src/prefix.mlb src/sources src/suffix.mlb \
+ | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
+ | sed 's/^\(.*\).lex$$/\1.lex.sml/'
+
src/domtool-server.mlb: Makefile src/prefix.mlb src/sources src/suffix.mlb
- cat src/prefix.mlb src/sources src/suffix.mlb \
- | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
- | sed 's/^\(.*\).lex$$/\1.lex.sml/' >src/domtool-server.mlb
+ $(MAKE_MLB_BASE) >src/domtool-server.mlb
echo "main-server.sml" >>src/domtool-server.mlb
src/domtool-client.mlb: Makefile src/prefix.mlb src/sources src/suffix.mlb
- cat src/prefix.mlb src/sources src/suffix.mlb \
- | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
- | sed 's/^\(.*\).lex$$/\1.lex.sml/' >src/domtool-client.mlb
+ $(MAKE_MLB_BASE) >src/domtool-client.mlb
echo "main-client.sml" >>src/domtool-client.mlb
src/domtool-slave.mlb: Makefile src/prefix.mlb src/sources src/suffix.mlb
- cat src/prefix.mlb src/sources src/suffix.mlb \
- | sed 's/^\(.*\).grm$$/\1.grm.sig\n\1.grm.sml/' \
- | sed 's/^\(.*\).lex$$/\1.lex.sml/' >src/domtool-slave.mlb
+ $(MAKE_MLB_BASE) >src/domtool-slave.mlb
echo "main-slave.sml" >>src/domtool-slave.mlb
openssl/smlnj/FFI/libssl.h.cm: openssl/openssl_sml.h
%.grm.sig %.grm.sml: %.grm
mlyacc $<
-bin/domtool-server: openssl/mlton/FFI/libssl.h.mlb \
- src/domtool-server.mlb src/domtool.lex.sml \
- src/domtool.grm.sig src/domtool.grm.sml \
- $(COMMON_DEPS) src/*.sig src/*.sml \
- src/plugins/*.sig src/plugins/*.sml
+COMMON_MLTON_DEPS := openssl/mlton/FFI/libssl.h.mlb \
+ src/domtool.lex.sml \
+ src/domtool.grm.sig src/domtool.grm.sml \
+ $(COMMON_DEPS) src/*.sig src/*.sml \
+ src/plugins/*.sig src/plugins/*.sml
+
+bin/domtool-server: $(COMMON_MLTON_DEPS) src/domtool-server.mlb
mlton -output bin/domtool-server -link-opt -ldl src/domtool-server.mlb
-bin/domtool-client: openssl/mlton/FFI/libssl.h.mlb \
- src/domtool-client.mlb src/domtool.lex.sml \
- src/domtool.grm.sig src/domtool.grm.sml \
- $(COMMON_DEPS) src/*.sig src/*.sml \
- src/plugins/*.sig src/plugins/*.sml
+bin/domtool-client: $(COMMON_MLTON_DEPS) src/domtool-client.mlb
mlton -output bin/domtool-client -link-opt -ldl src/domtool-client.mlb
-bin/domtool-slave: openssl/mlton/FFI/libssl.h.mlb \
- src/domtool-slave.mlb src/domtool.lex.sml \
- src/domtool.grm.sig src/domtool.grm.sml \
- $(COMMON_DEPS) src/*.sig src/*.sml \
- src/plugins/*.sig src/plugins/*.sml
+bin/domtool-slave: $(COMMON_MLTON_DEPS) src/domtool-slave.mlb
mlton -output bin/domtool-slave -link-opt -ldl src/domtool-slave.mlb
install:
end
val () = Slave.registerFileHandler (fn fs =>
- case findVhostUser (#file fs) of
- NONE => print ("Can't find user in " ^ #file fs ^ "! Taking no action.\n")
- | SOME user =>
- let
- val spl = OS.Path.splitDirFile (#file fs)
- in
- if String.isSuffix ".vhost" (#file spl)
- orelse String.isSuffix ".vhost_ssl" (#file spl) then
- (vhostsChanged := true;
- case #action fs of
- Slave.Delete =>
- let
- val {base, ...} = OS.Path.splitBaseExt (#file spl)
-
- val logname = OS.Path.joinDirFile
- {dir = Config.Apache.logDir,
- file = user}
- in
+ let
+ val spl = OS.Path.splitDirFile (#file fs)
+ in
+ if String.isSuffix ".vhost" (#file spl)
+ orelse String.isSuffix ".vhost_ssl" (#file spl) then
+ case findVhostUser (#file fs) of
+ NONE => print ("Can't find user in " ^ #file fs ^ "! Taking no action.\n")
+ | SOME user =>
+ let
+ val realVhostFile = OS.Path.joinDirFile
+ {dir = Config.Apache.confDir,
+ file = #file spl}
+
+ val realLogDir = OS.Path.joinDirFile
+ {dir = Config.homeBase,
+ file = user}
+ val realLogDir = OS.Path.joinDirFile
+ {dir = realLogDir,
+ file = "apache"}
+ val realLogDir = OS.Path.joinDirFile
+ {dir = realLogDir,
+ file = "log"}
+ val realLogDir = OS.Path.joinDirFile
+ {dir = realLogDir,
+ file = Slave.hostname ()}
+ val {base, ...} = OS.Path.splitBaseExt (#file spl)
+ val realLogDir = OS.Path.joinDirFile
+ {dir = realLogDir,
+ file = base}
+ in
+ vhostsChanged := true;
+ case #action fs of
+ Slave.Delete =>
+ (ignore (OS.Process.system (Config.rm
+ ^ " -rf "
+ ^ realVhostFile));
ignore (OS.Process.system (Config.rm
^ " -rf "
- ^ Config.Apache.confDir
- ^ "/"
- ^ #file spl));
- Slave.writeList (logname,
- List.filter (fn s => s <> base)
- (Slave.readList logname))
- end
-
- | Slave.Add =>
- let
- val _ =
- OS.Process.system (Config.cp
- ^ " "
- ^ #file fs
- ^ " "
- ^ Config.Apache.confDir
- ^ "/"
- ^ #file spl)
-
- val {base, ...} = OS.Path.splitBaseExt (#file spl)
-
- val logname = OS.Path.joinDirFile
- {dir = Config.Apache.logDir,
- file = user}
-
- val outf = TextIO.openAppend logname
- in
- TextIO.output (outf, base);
- TextIO.output1 (outf, #"\n");
- TextIO.closeOut outf
- end
-
- | _ =>
- ignore (OS.Process.system (Config.cp
- ^ " "
- ^ #file fs
- ^ " "
- ^ Config.Apache.confDir
- ^ "/"
- ^ #file spl)))
- else
- ()
- end)
+ ^ realLogDir)))
+ | Slave.Add =>
+ (ignore (OS.Process.system (Config.cp
+ ^ " "
+ ^ #file fs
+ ^ " "
+ ^ realVhostFile));
+ OS.FileSys.mkDir realLogDir)
+
+ | _ =>
+ ignore (OS.Process.system (Config.cp
+ ^ " "
+ ^ #file fs
+ ^ " "
+ ^ realVhostFile))
+ end
+ else
+ ()
+ end)
val () = Slave.registerPostHandler
(fn () =>
else
()))
-val vhostFiles : TextIO.outstream list ref = ref []
-fun write s = app (fn file => TextIO.output (file, s)) (!vhostFiles)
+val vhostFiles : (string * TextIO.outstream) list ref = ref []
+fun write' s = app (fn (node, file) => TextIO.output (file, s node)) (!vhostFiles)
+fun write s = app (fn (_, file) => TextIO.output (file, s)) (!vhostFiles)
val rewriteEnabled = ref false
val currentVhost = ref ""
val currentVhostId = ref ""
-val pre = ref (fn _ : {nodes : string list, id : string, hostname : string} => ())
+val pre = ref (fn _ : {user : string, nodes : string list, id : string, hostname : string} => ())
fun registerPre f =
let
val old = !pre
else
"80");
TextIO.output (file, ">\n");
- file
+ TextIO.output (file, "\tErrorLog ");
+ TextIO.output (file, Config.homeBase);
+ TextIO.output (file, "/");
+ TextIO.output (file, user);
+ TextIO.output (file, "/apache/log/");
+ TextIO.output (file, node);
+ TextIO.output (file, "/");
+ TextIO.output (file, vhostId);
+ TextIO.output (file, "/error.log\n\tCustomLog ");
+ TextIO.output (file, Config.homeBase);
+ TextIO.output (file, "/");
+ TextIO.output (file, user);
+ TextIO.output (file, "/apache/log/");
+ TextIO.output (file, node);
+ TextIO.output (file, "/");
+ TextIO.output (file, vhostId);
+ TextIO.output (file, "/access.log combined\n");
+ (Config.homeBase ^ "/" ^ user ^ "/apache/log/"
+ ^ node ^ "/" ^ vhostId, file)
end)
nodes;
write "\tServerName ";
write docroot;
write "\n\tServerAdmin ";
write sadmin;
- write "\n\tErrorLog ";
- write Config.Apache.logDir;
- write "/";
- write vhostId;
- write "/error.log\n\tCustomLog ";
- write Config.Apache.logDir;
- write "/";
- write vhostId;
- write "/access.log combined\n";
- !pre {nodes = nodes, id = vhostId, hostname = fullHost}
+ write "\n";
+ !pre {user = user, nodes = nodes, id = vhostId, hostname = fullHost}
end,
fn () => (!post ();
write "</VirtualHost>\n";
- app TextIO.closeOut (!vhostFiles)))
+ app (TextIO.closeOut o #2) (!vhostFiles)))
val () = Env.container_one "location"
("prefix", Env.string)
(fn level =>
(checkRewrite ();
write "\tRewriteLog ";
- write Config.Apache.logDir;
- write "/";
- write (!currentVhostId);
+ write' (fn x => x);
write "/rewrite.log\n\tRewriteLogLevel ";
write (Int.toString level);
write "\n"))
val write = ref (fn _ : string => ())
val () = Apache.registerPre
- (fn {nodes, id, hostname} =>
+ (fn {user, nodes, id, hostname} =>
let
- val fds = map (fn node => Domain.domainFile {node = node,
- name = id ^ ".wbl"}) nodes
+ val fds = map (fn node =>
+ let
+ val fd = Domain.domainFile {node = node,
+ name = id ^ ".wbl"}
+ in
+ TextIO.output (fd, "LogFile\t");
+ TextIO.output (fd, Config.homeBase);
+ TextIO.output (fd, "/apache/log/");
+ TextIO.output (fd, node);
+ TextIO.output (fd, hostname);
+ TextIO.output (fd, "/access.log\nOutputDir\t");
+ TextIO.output (fd, Config.Webalizer.outputDir);
+ TextIO.output (fd, "/");
+ TextIO.output (fd, node);
+ TextIO.output (fd, "/");
+ TextIO.output (fd, id);
+ TextIO.output (fd, "\n");
+ fd
+ end) 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\t";
!write hostname;
!write "\nHideSite\t";
!write hostname;