Backup MX for External MX affects Postfix transport.

This commit is contained in:
Michael Hierweck 2012-10-31 15:34:49 +01:00
parent b673617734
commit d3ceb761a8

View File

@ -59,7 +59,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, pacInetAddr), queueName + ".hostsharing.net");
}
for (String queueName : config.getProperty("queues.mail").split(",")) {
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, domName, pac), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
}
templateVars = new HashMap<String, String>();
templateVars.put("PAC", pacName);
@ -95,7 +95,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
WaitingTasksProcessor processor = new WaitingTasksProcessor(createApacheVHostSetupProcessor(em, dom, templateVars));
Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.mail").split(",")) {
processor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net");
processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
}
return processor;
}
@ -111,8 +111,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
mainProcessor.appendProcessor(queueName, createDNSServerRemoveProcessor(domName), queueName + ".hostsharing.net");
}
for (String queueName : config.getProperty("queues.mail").split(",")) {
mainProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createMailinUnsetupProcessor(em, dom), queueName + ".hostsharing.net");
}
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
return mainProcessor;
@ -176,17 +175,30 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" && invoke-rc.d bind9 reload");
}
private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException {
private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
String inetAddr = pac.getCurINetAddr().getInetAddr();
return new CompoundProcessor(
CompoundProcessor cp = new CompoundProcessor(
createPostgreyConfiguration(em),
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
domName + " anything\n" +
"." + domName + " anything\n"),
new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport",
domName + " smtp:" + inetAddr + ":225\n" +
"." + domName + " smtp:" + inetAddr + ":225\n")
);
dom.getName() + " anything\n" +
"." + dom.getName() + " anything\n"));
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
query.setParameter("domname", dom.getName());
query.setParameter("option", "backupmxforexternalmx");
if (query.getResultList().isEmpty()) {
cp.appendProcessor(
new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport",
dom.getName() + " smtp:" + inetAddr + ":225\n" +
"." + dom.getName() + " smtp:" + inetAddr + ":225\n")
);
} else {
cp.appendProcessor(
new ShellProcessor(
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport")
);
}
return cp;
}
private Processor createPostgreyConfiguration(EntityManager em) throws ProcessorException {
@ -213,12 +225,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
);
}
private Processor createMailinDeleteProcessor(String domName) {
Processor mailQueueProcessor = new ShellProcessor(
"postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '" + domName + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/transport");
private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
Processor mailQueueProcessor = new CompoundProcessor(
createPostgreyConfiguration(em),
new ShellProcessor(
"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"));
return mailQueueProcessor;
}