X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/0da1c677dd0a079c9e985af37688cc9e833fc196..55d4a2686f9334ccd03602c86e43395acef9537d:/src/plugins/apache.sml diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index f476c97..4ea0389 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -25,9 +25,9 @@ open Ast val _ = Env.type_one "web_node" Env.string (fn node => - List.exists (fn x => x = node) Config.Apache.webNodes_all + List.exists (fn (x, _) => x = node) Config.Apache.webNodes_all orelse (Domain.hasPriv "www" - andalso List.exists (fn x => x = node) Config.Apache.webNodes_admin)) + andalso List.exists (fn (x, _) => x = node) Config.Apache.webNodes_admin)) val _ = Env.registerFunction ("web_node_to_node", fn [e] => SOME e @@ -225,6 +225,17 @@ fun findVhostUser fname = before TextIO.closeIn inf end handle _ => NONE +val webNodes_full = Config.Apache.webNodes_all @ Config.Apache.webNodes_admin + +fun isVersion1 node = + List.exists (fn x => x = (node, true)) webNodes_full + +fun imVersion1 () = isVersion1 (Slave.hostname ()) + +fun down () = if imVersion1 () then Config.Apache.down1 else Config.Apache.down +fun undown () = if imVersion1 () then Config.Apache.undown1 else Config.Apache.undown +fun reload () = if imVersion1 () then Config.Apache.reload1 else Config.Apache.reload + val () = Slave.registerFileHandler (fn fs => let val spl = OS.Path.splitDirFile (#file fs) @@ -257,9 +268,7 @@ val () = Slave.registerFileHandler (fn fs => file = Slave.hostname ()} val {base, ...} = OS.Path.splitBaseExt (#file spl) - val realLogDir = OS.Path.joinDirFile - {dir = realLogDir, - file = base} + val realLogDir = OS.Path.concat (realLogDir, base) in if String.isSuffix ".vhost_ssl" (#file spl) then realLogDir ^ ".ssl" @@ -273,7 +282,7 @@ val () = Slave.registerFileHandler (fn fs => (if !logDeleted then () else - (ignore (OS.Process.system Config.Apache.down); + (ignore (OS.Process.system (down ())); logDeleted := true); ignore (OS.Process.system (Config.rm ^ " -rf " @@ -310,7 +319,7 @@ val () = Slave.registerFileHandler (fn fs => if !logDeleted then () else - (ignore (OS.Process.system Config.Apache.down); + (ignore (OS.Process.system (down ())); logDeleted := true); ignore (OS.Process.system (Config.rm ^ " -rf " @@ -331,7 +340,7 @@ val () = Slave.registerFileHandler (fn fs => val () = Slave.registerPostHandler (fn () => (if !vhostsChanged then - Slave.shellF ([if !logDeleted then Config.Apache.undown else Config.Apache.reload], + Slave.shellF ([if !logDeleted then undown () else reload ()], fn cl => "Error reloading Apache with " ^ cl) else ())) @@ -418,19 +427,25 @@ val () = Env.containerV_one "vhost" TextIO.output (file, "/"); TextIO.output (file, vhostId); TextIO.output (file, "/access.log combined\n"); + TextIO.output (file, "\tServerName "); + TextIO.output (file, fullHost); + if suexec then + if isVersion1 node then + (TextIO.output (file, "\n\tUser "); + TextIO.output (file, user); + TextIO.output (file, "\n\tGroup "); + TextIO.output (file, group)) + else + (TextIO.output (file, "\n\tSuexecUserGroup "); + TextIO.output (file, user); + TextIO.output (file, " "); + TextIO.output (file, group)) + else + (); (Domain.homedirOf user ^ "/apache/log/" ^ node ^ "/" ^ vhostId, file) end) nodes; - write "\tServerName "; - write fullHost; - if suexec then - (write "\n\tSuexecUserGroup "; - write user; - write " "; - write group) - else - (); write "\n\tDocumentRoot "; write docroot; write "\n\tServerAdmin ";