X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/8cbb96323335d1a2b42a9daac94a9d538ab93536..c17d0537db6e55a6b2bbd1a459542a5fbb44a68f:/src/plugins/apache.sml?ds=sidebyside diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index 64ebc7b..4e07e4e 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -236,6 +236,7 @@ fun isWaklog node = 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 +fun fixperms () = if imVersion1 () then Config.Apache.fixperms1 else Config.Apache.fixperms fun logDir {user, node, vhostId} = String.concat [Config.Apache.logDirOf (isVersion1 node) user, @@ -271,21 +272,31 @@ val () = Slave.registerFileHandler (fn fs => logDir {user = valOf user, node = Slave.hostname (), vhostId = vhostId} + + fun backupLogs () = + OS.Path.joinDirFile + {dir = Config.Apache.backupLogDirOf + (isVersion1 (Slave.hostname ())), + file = vhostId} in 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 ())); + ignore (OS.Process.system (fixperms ())); + logDeleted := true); + ignore (OS.Process.system (Config.rm + ^ " -rf " + ^ realVhostFile)); + Slave.moveDirCreate {from = ldir, + to = backupLogs ()} + end | Slave.Add => let val rld = realLogDir user @@ -298,7 +309,8 @@ val () = Slave.registerFileHandler (fn fs => if Posix.FileSys.access (rld, []) then () else - Slave.mkDirAll rld + Slave.moveDirCreate {from = backupLogs (), + to = rld} end | _ => @@ -890,4 +902,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