maildir created by salt, remove pac-slices

This commit is contained in:
Peter Hormanns 2024-11-26 14:48:10 +01:00
parent a0f412f074
commit 56908948a2
2 changed files with 3 additions and 10 deletions

View File

@ -98,6 +98,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
createUnlinkSiteProc(pac.getName() + ".hostsharing.net"),
createHiveDNSRemoveProcessor(domainName),
createAccountingRulesProc(),
new ShellProcessor("rm -rf '/etc/systemd/system/pacs-" + pac.getName() + ".slice'"),
new ShellProcessor("salt-call state.sls pacs >/dev/null 2>&1")), "remove packet");
final Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.dns").split(",")) {

View File

@ -28,7 +28,6 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
+ ":" + user.getComment() + ":" + user.getHomedir()
+ ":" + user.getShell() + "\n"));
appendSetHomeACLProcessor(aCP, user);
appendMakeMaildirProcessor(aCP, user);
aCP.appendProcessor(new ShellProcessor("salt-call state.sls pacs >/dev/null 2>&1"));
return aCP;
}
@ -56,6 +55,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
UnixUser user = (UnixUser) entity;
String uid = user.getName();
long userId = user.getUserId();
String pac = user.getPac().getName();
if (uid != null && uid.length() > 4) {
Processor killProcessesProc = new ShellProcessor("killall -TERM -u " + uid + " && sleep 5 && killall -KILL -u " + uid + " && sleep 5 || true");
@ -70,6 +70,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
proc.appendProcessor(new ShellProcessor("rm -f '/var/mail/" + uid + "'"));
proc.appendProcessor(new ShellProcessor("rm -f '/var/lib/systemd/linger/" + uid + "'"));
proc.appendProcessor(new ShellProcessor("rm -rf '/home/storage/" + pac + "/users/" + ( uid.length() > 6 ? uid.substring(6) : '_' ) + "/'"));
proc.appendProcessor(new ShellProcessor("rm -rf '/etc/systemd/system/user@" + userId + ".service.d'"));
proc.appendProcessor(new ShellProcessor("salt-call state.sls pacs >/dev/null 2>&1"));
return proc;
}
@ -80,13 +81,4 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
aCP.appendProcessor(new ShellProcessor("chmod 700 " + user.getHomedir()));
}
private void appendMakeMaildirProcessor(CompoundProcessor aCP, UnixUser user) {
aCP.appendProcessor(
new ShellProcessor(
"su -l " + user.getName() + " -s \"/bin/bash\" -c \"maildirmake.dovecot " +
user.getHomedir() + "/Maildir" +
"\""
));
}
}