Initial Apache 1.3 support
authorAdam Chlipala <adamc@hcoop.net>
Tue, 10 Apr 2007 02:22:51 +0000 (02:22 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Tue, 10 Apr 2007 02:22:51 +0000 (02:22 +0000)
configDefault/apache.cfg
configDefault/apache.csg
scripts/domtool-publish
scripts/domtool-reset-global
src/compat_mlton.sml
src/plugins/apache.sml

index 4b625bb..33ca610 100644 (file)
@@ -4,10 +4,14 @@ val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache"
 val down = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-down"
 val undown = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-undown"
 
 val down = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-down"
 val undown = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-undown"
 
+val reload1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3"
+val down1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-down"
+val undown1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-undown"
+
 val confDir = "/var/domtool/vhosts"
 
 val confDir = "/var/domtool/vhosts"
 
-val webNodes_all = ["mire"]
-val webNodes_admin = ["deleuze"]
+val webNodes_all = [("mire", true)]
+val webNodes_admin = [("deleuze", false)]
 
 val webNodes_default = ["mire"]
 
 
 val webNodes_default = ["mire"]
 
index 28188ac..0491805 100644 (file)
@@ -4,10 +4,14 @@ signature APACHE_CONFIG = sig
     val        down : string
     val        undown : string
 
     val        down : string
     val        undown : string
 
+    val reload1 : string
+    val        down1 : string
+    val        undown1 : string
+
     val confDir : string
 
     val confDir : string
 
-    val        webNodes_all : string list
-    val webNodes_admin : string list
+    val        webNodes_all : (string * bool) list
+    val webNodes_admin : (string * bool) list
     val webNodes_default : string list
 
     val proxyTargets : string list
     val webNodes_default : string list
 
     val proxyTargets : string list
index b84f1df..acfbe6d 100755 (executable)
@@ -25,6 +25,17 @@ case $1 in
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
                /etc/init.d/apache2 start
        ;;
                /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache2/vhosts/
                /etc/init.d/apache2 start
        ;;
+       apache1.3)
+               /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
+               /etc/init.d/apache reload
+       ;;
+       apache1.3-down)
+               /etc/init.d/apache stop
+       ;;
+       apache1.3-undown)
+               /usr/bin/rsync -r --delete /var/domtool/vhosts/ /etc/apache/vhosts/
+               /etc/init.d/apache start
+       ;;
        bind)
                /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/
                /bin/cp /var/domtool/named.conf.local /etc/bind/
        bind)
                /usr/bin/rsync -r --delete /var/domtool/zones/ /etc/bind/zones/
                /bin/cp /var/domtool/named.conf.local /etc/bind/
index d862feb..748f9d9 100644 (file)
@@ -11,8 +11,8 @@ mkdir ~domtool/webalizer/output
 mkdir ~domtool/webalizer/output/deleuze
 mkdir ~domtool/webalizer/output/mire
 
 mkdir ~domtool/webalizer/output/deleuze
 mkdir ~domtool/webalizer/output/mire
 
-for usr in `ls /afs/hcoop/usr`
-do
-       rm -rf /afs/hcoop/usr/$usr/apache/log/mire/*
-       rm -rf /afs/hcoop/usr/$usr/apache/log/deleuze/*
-done
+#for usr in `ls /afs/hcoop/usr`
+#do
+#      rm -rf /afs/hcoop/usr/$usr/apache/log/mire/*
+#      rm -rf /afs/hcoop/usr/$usr/apache/log/deleuze/*
+#done
index 7b28b7e..9a6b60f 100644 (file)
@@ -26,6 +26,5 @@ end
 val _ = let
     open MLton.Signal
 in
 val _ = let
     open MLton.Signal
 in
-    setHandler (Posix.Signal.pipe, Handler.ignore);
-    setHandler (Posix.Signal.chld, Handler.ignore)
+    setHandler (Posix.Signal.pipe, Handler.ignore)
 end
 end
index 7183bcb..4ea0389 100644 (file)
@@ -25,9 +25,9 @@ open Ast
 val _ = Env.type_one "web_node"
        Env.string
        (fn node =>
 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"
            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
 
 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
 
        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)
 val () = Slave.registerFileHandler (fn fs =>
                                       let
                                           val spl = OS.Path.splitDirFile (#file fs)
@@ -271,7 +282,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                                               (if !logDeleted then
                                                                    ()
                                                                else
                                                               (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 "
                                                                     logDeleted := true);
                                                                ignore (OS.Process.system (Config.rm
                                                                                           ^ " -rf "
@@ -308,7 +319,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                                                        if !logDeleted then
                                                                            ()
                                                                        else
                                                                        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 "
                                                                             logDeleted := true);
                                                                        ignore (OS.Process.system (Config.rm
                                                                                                   ^ " -rf "
@@ -329,7 +340,7 @@ val () = Slave.registerFileHandler (fn fs =>
 val () = Slave.registerPostHandler
         (fn () =>
             (if !vhostsChanged then
 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
                  ()))
                                fn cl => "Error reloading Apache with " ^ cl)
              else
                  ()))
@@ -416,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, "/");
                                           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;
                                           (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 ";
                 write "\n\tDocumentRoot ";
                 write docroot;
                 write "\n\tServerAdmin ";