Testing log directory backup
[hcoop/domtool2.git] / src / plugins / apache.sml
index 64ebc7b..1f0fe83 100644 (file)
@@ -275,17 +275,21 @@ val () = Slave.registerFileHandler (fn fs =>
                                                           vhostsChanged := true;
                                                           case #action fs of
                                                               Slave.Delete =>
-                                                              (if !logDeleted then
-                                                                   ()
-                                                               else
-                                                                   (ignore (OS.Process.system (down ()));
-                                                                    logDeleted := true);
-                                                               ignore (OS.Process.system (Config.rm
-                                                                                          ^ " -rf "
-                                                                                          ^ realVhostFile));
-                                                               ignore (OS.Process.system (Config.rm
-                                                                                          ^ " -rf "
-                                                                                          ^ realLogDir oldUser)))
+                                                              let
+                                                                  val ldir = realLogDir oldUser
+                                                              in
+                                                                  if !logDeleted then
+                                                                      ()
+                                                                  else
+                                                                      (ignore (OS.Process.system (down ()));
+                                                                       logDeleted := true);
+                                                                  ignore (OS.Process.system (Config.rm
+                                                                                             ^ " -rf "
+                                                                                             ^ realVhostFile));
+                                                                  Slave.moveDirCreate {from = ldir,
+                                                                                       to = Config.Apache.backupLogDirOf
+                                                                                                (isVersion1 (Slave.hostname ()))}
+                                                              end
                                                             | Slave.Add =>
                                                               let
                                                                   val rld = realLogDir user
@@ -298,7 +302,9 @@ val () = Slave.registerFileHandler (fn fs =>
                                                                   if Posix.FileSys.access (rld, []) then
                                                                       ()
                                                                   else
-                                                                      Slave.mkDirAll rld
+                                                                      Slave.moveDirCreate {from = Config.Apache.backupLogDirOf
+                                                                                                      (isVersion1 (Slave.hostname ())),
+                                                                                           to = rld}
                                                               end
                                                               
                                                             | _ =>
@@ -890,4 +896,10 @@ val () = Env.action_two "setEnv"
 val () = Domain.registerResetLocal (fn () =>
                                       ignore (OS.Process.system (Config.rm ^ " -rf /var/domtool/vhosts/*")))
 
+val () = Domain.registerDescriber (Domain.considerAll
+                                  [Domain.Extension {extension = "vhost",
+                                                     heading = fn host => "Web vhost " ^ host},
+                                   Domain.Extension {extension = "vhost_ssl",
+                                                     heading = fn host => "SSL web vhost " ^ host}])
+
 end