Move Postgrey configuration processor back to domain module.
This commit is contained in:
parent
775f9f98e6
commit
53e5c85bce
@ -5,6 +5,11 @@
|
|||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
@ -13,5 +18,6 @@
|
|||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.hsadmin.mods.dom;
|
package de.hsadmin.mods.dom;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -43,6 +44,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom), "Setup Apache VHost");
|
mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom), "Setup Apache VHost");
|
||||||
mainProcessor.appendProcessor(hiveName, createACMEBotProcessor(em, dom), "Setup ACMEBot");
|
mainProcessor.appendProcessor(hiveName, createACMEBotProcessor(em, dom), "Setup ACMEBot");
|
||||||
mainProcessor.appendProcessor(hiveName, createTriggerAcmebotProcessor(em, dom), "Trigger ACMEBot");
|
mainProcessor.appendProcessor(hiveName, createTriggerAcmebotProcessor(em, dom), "Trigger ACMEBot");
|
||||||
|
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||||
|
mainProcessor.appendProcessor(queueName, createPostgreyConfigurationUpdateProcessor(em), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
return mainProcessor;
|
return mainProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +57,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
final Processor triggerAcmebotProcessor = createTriggerAcmebotProcessor(em, dom);
|
final Processor triggerAcmebotProcessor = createTriggerAcmebotProcessor(em, dom);
|
||||||
final WaitingTasksProcessor processor = new WaitingTasksProcessor(
|
final WaitingTasksProcessor processor = new WaitingTasksProcessor(
|
||||||
new CompoundProcessor(apacheVHostSetupProcessor, letencryptSetupProcessor, triggerAcmebotProcessor));
|
new CompoundProcessor(apacheVHostSetupProcessor, letencryptSetupProcessor, triggerAcmebotProcessor));
|
||||||
|
final Config config = Config.getInstance();
|
||||||
|
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||||
|
processor.appendProcessor(queueName, createPostgreyConfigurationUpdateProcessor(em), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
return processor;
|
return processor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +76,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
}
|
}
|
||||||
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
|
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
|
||||||
mainProcessor.appendProcessor(dom.getHiveName(), createACMEBotProcessor(em, dom), "remove letsencrypt config");
|
mainProcessor.appendProcessor(dom.getHiveName(), createACMEBotProcessor(em, dom), "remove letsencrypt config");
|
||||||
|
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||||
|
mainProcessor.appendProcessor(queueName, createPostgreyConfigurationUpdateProcessor(em), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
return mainProcessor;
|
return mainProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,4 +301,27 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties"));
|
new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Processor createPostgreyConfigurationUpdateProcessor(EntityManager em) throws ProcessorException {
|
||||||
|
final List<Domain> whitelistDoms = new ArrayList<Domain>();
|
||||||
|
final Query query = em.createQuery("SELECT DISTINCT dom FROM Domains dom WHERE NOT EXISTS "
|
||||||
|
+ "(SELECT postgreyDom FROM Domains postgreyDom "
|
||||||
|
+ "WHERE postgreyDom.domainoptions.name = :option"
|
||||||
|
+ "AND postgreyDom.name = dom.name)");
|
||||||
|
query.setParameter("option", "greylisting");
|
||||||
|
final List<?> result = query.getResultList();
|
||||||
|
for (Object dom : result) {
|
||||||
|
if (dom instanceof Domain) {
|
||||||
|
whitelistDoms.add((Domain) dom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final HashMap<String, Object> templateVars = new HashMap<String, Object>();
|
||||||
|
templateVars.put("whitelist", whitelistDoms);
|
||||||
|
return new CompoundProcessor(
|
||||||
|
new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm", templateVars,
|
||||||
|
"/etc/postgrey/whitelist_recipients.tmp", true),
|
||||||
|
new ShellProcessor(
|
||||||
|
" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) "
|
||||||
|
+ "|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package de.hsadmin.mods.email;
|
package de.hsadmin.mods.email;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
@ -13,7 +11,6 @@ import de.hsadmin.core.qserv.EntityProcessorFactory;
|
|||||||
import de.hsadmin.core.qserv.Processor;
|
import de.hsadmin.core.qserv.Processor;
|
||||||
import de.hsadmin.core.qserv.ProcessorException;
|
import de.hsadmin.core.qserv.ProcessorException;
|
||||||
import de.hsadmin.core.qserv.ShellProcessor;
|
import de.hsadmin.core.qserv.ShellProcessor;
|
||||||
import de.hsadmin.core.qserv.VelocityProcessor;
|
|
||||||
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.dom.Domain;
|
import de.hsadmin.mods.dom.Domain;
|
||||||
@ -97,32 +94,9 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
return result.size();
|
return result.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createPostgreyConfigurationUpdateProcessor(EntityManager em) throws ProcessorException {
|
|
||||||
final List<Domain> whitelistDoms = new ArrayList<Domain>();
|
|
||||||
final Query query = em.createQuery("SELECT DISTINCT dom FROM Domains dom WHERE NOT EXISTS "
|
|
||||||
+ "(SELECT postgreyDom FROM Domains postgreyDom "
|
|
||||||
+ "WHERE postgreyDom.domainoptions.name = :option"
|
|
||||||
+ "AND postgreyDom.name = dom.name)");
|
|
||||||
query.setParameter("option", "greylisting");
|
|
||||||
final List<?> result = query.getResultList();
|
|
||||||
for (Object dom : result) {
|
|
||||||
if (dom instanceof Domain) {
|
|
||||||
whitelistDoms.add((Domain) dom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final HashMap<String, Object> templateVars = new HashMap<String, Object>();
|
|
||||||
templateVars.put("whitelist", whitelistDoms);
|
|
||||||
return new CompoundProcessor(
|
|
||||||
new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm", templateVars,
|
|
||||||
"/etc/postgrey/whitelist_recipients.tmp", true),
|
|
||||||
new ShellProcessor(
|
|
||||||
" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) "
|
|
||||||
+ "|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
|
private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
|
||||||
final String inetAddr = pac.getCurINetAddr().getInetAddr();
|
final String inetAddr = pac.getCurINetAddr().getInetAddr();
|
||||||
final CompoundProcessor cp = new CompoundProcessor(createPostgreyConfigurationUpdateProcessor(em));
|
final CompoundProcessor cp = new CompoundProcessor();
|
||||||
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
|
cp.appendProcessor(new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
|
||||||
dom.getName() + " anything\n" +
|
dom.getName() + " anything\n" +
|
||||||
"." + dom.getName() + " anything\n"));
|
"." + dom.getName() + " anything\n"));
|
||||||
@ -133,7 +107,7 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
|
private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
|
||||||
final CompoundProcessor cp = new CompoundProcessor(createPostgreyConfigurationUpdateProcessor(em));
|
final CompoundProcessor cp = new CompoundProcessor();
|
||||||
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/relaydomains",
|
cp.appendProcessor(new ShellProcessor("postmap -d - /etc/postfix-mailin/relaydomains",
|
||||||
dom.getName() + "\n" +
|
dom.getName() + "\n" +
|
||||||
"." + dom.getName() + "\n"));
|
"." + dom.getName() + "\n"));
|
||||||
|
Loading…
Reference in New Issue
Block a user