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,
val oldUser = findVhostUser realVhostFile
in
if (oldUser = NONE andalso #action fs <> Slave.Add)
- orelse (user = NONE andalso #action fs <> Slave.Delete) then
+ orelse (user = NONE andalso not (Slave.isDelete (#action fs))) then
print ("Can't find user in " ^ #file fs ^ " or " ^ realVhostFile ^ "! Taking no action.\n")
else
let
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)))
+ Slave.Delete _ =>
+ 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
if Posix.FileSys.access (rld, []) then
()
else
- Slave.mkDirAll rld
+ Slave.moveDirCreate {from = backupLogs (),
+ to = rld}
end
| _ =>
val () = Domain.registerDescriber (Domain.considerAll
[Domain.Extension {extension = "vhost",
- heading = fn host => "Web vhost: " ^ host},
+ heading = fn host => "Web vhost " ^ host},
Domain.Extension {extension = "vhost_ssl",
- heading = fn host => "SSL web vhost: " ^ host}])
+ heading = fn host => "SSL web vhost " ^ host}])
end