Cleanup.
This commit is contained in:
parent
f3a2ac9123
commit
b29374939c
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
@ -161,19 +162,19 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
"." + dom.getName() + " smtp:" + inetAddr + ":225\n")
|
"." + dom.getName() + " smtp:" + inetAddr + ":225\n")
|
||||||
);
|
);
|
||||||
cp.appendProcessor(
|
cp.appendProcessor(
|
||||||
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relayrecipients",
|
new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients",
|
||||||
"@" + dom.getName() + " anything\n")
|
"@" + dom.getName() + "\n")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
cp.appendProcessor(
|
cp.appendProcessor(
|
||||||
new ShellProcessor(
|
new ShellProcessor("postmap -d - /etc/postfix-mailin/transport",
|
||||||
"postmap -d '@" + dom.getName() + "' /etc/postfix-mailin/relayrecipients")
|
dom.getName() + "\n" +
|
||||||
);
|
"." + dom.getName() + "\n")
|
||||||
cp.appendProcessor(
|
|
||||||
new ShellProcessor(
|
|
||||||
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " +
|
|
||||||
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport")
|
|
||||||
);
|
);
|
||||||
|
cp.appendProcessor(
|
||||||
|
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relayrecipients",
|
||||||
|
"@" + dom.getName() + " anything\n")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
@ -202,14 +203,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
|
private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
|
||||||
Processor mailQueueProcessor = new CompoundProcessor(
|
final CompoundProcessor mailQueueProcessor = new CompoundProcessor(createPostgreyConfiguration(em));
|
||||||
createPostgreyConfiguration(em),
|
mailQueueProcessor.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients",
|
||||||
new ShellProcessor(
|
dom.getName() + "\n" +
|
||||||
"postmap -d '@" + dom.getName() + "' /etc/postfix-mailin/relayrecpients && " +
|
"." + dom.getName() + "\n" +
|
||||||
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/relaydomains && " +
|
"@" + dom.getName() + "\n"));
|
||||||
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " +
|
mailQueueProcessor.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/transports",
|
||||||
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/relaydomains && " +
|
dom.getName() + "\n" +
|
||||||
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport"));
|
"." + dom.getName() + "\n"));
|
||||||
return mailQueueProcessor;
|
return mailQueueProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,16 +12,18 @@ import de.hsadmin.core.qserv.Processor;
|
|||||||
import de.hsadmin.core.qserv.ShellProcessor;
|
import de.hsadmin.core.qserv.ShellProcessor;
|
||||||
import de.hsadmin.core.qserv.WaitingTasksProcessor;
|
import de.hsadmin.core.qserv.WaitingTasksProcessor;
|
||||||
import de.hsadmin.core.util.Config;
|
import de.hsadmin.core.util.Config;
|
||||||
import de.hsadmin.mods.pac.Pac;
|
|
||||||
|
|
||||||
public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
||||||
|
|
||||||
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) {
|
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) {
|
||||||
// TODO: combine both keys in a single call (optimization)
|
// TODO: combine both keys in a single call (optimization)
|
||||||
EMailAddress email = (EMailAddress) entity;
|
|
||||||
CompoundProcessor cp = new CompoundProcessor();
|
CompoundProcessor cp = new CompoundProcessor();
|
||||||
cp.appendProcessor(
|
EMailAddress email = (EMailAddress) entity;
|
||||||
new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual", email.getFullDomain() + " -"));
|
if (emailAddressCount(em, email) == 1) {
|
||||||
|
// first email address added
|
||||||
|
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual",
|
||||||
|
email.getFullDomain() + " -"));
|
||||||
|
}
|
||||||
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual",
|
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/virtual",
|
||||||
email.getEMailAddress() + " " + email.getTarget()));
|
email.getEMailAddress() + " " + email.getTarget()));
|
||||||
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
||||||
@ -46,17 +48,17 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
EMailAddress email = (EMailAddress) entity;
|
EMailAddress email = (EMailAddress) entity;
|
||||||
if (emailAddressCount(em, email) == 0) {
|
if (emailAddressCount(em, email) == 0) {
|
||||||
// last email address removed
|
// last email address removed
|
||||||
String fullDomain = email.getFullDomain();
|
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual",
|
||||||
cp.appendProcessor(new ShellProcessor("postmap -d '" + fullDomain + "' /etc/postfix-mailin/virtual"));
|
email.getFullDomain() + "\n"));
|
||||||
}
|
}
|
||||||
cp.appendProcessor(
|
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/virtual",
|
||||||
new ShellProcessor("postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/virtual"));
|
email.getEMailAddress() + "\n"));
|
||||||
Config config = Config.getInstance();
|
Config config = Config.getInstance();
|
||||||
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
|
||||||
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||||
waitingTasksProcessor.appendProcessor(queueName,
|
waitingTasksProcessor.appendProcessor(queueName,
|
||||||
new ShellProcessor(
|
new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients",
|
||||||
"postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/relayrecipients"),
|
email.getEMailAddress() + "\n"),
|
||||||
"Remove from relayrecipients");
|
"Remove from relayrecipients");
|
||||||
}
|
}
|
||||||
return waitingTasksProcessor;
|
return waitingTasksProcessor;
|
||||||
|
Loading…
Reference in New Issue
Block a user