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