update and deleteprocessor for domainoptions
This commit is contained in:
parent
b9f140d19d
commit
63a31ab23d
@ -149,8 +149,8 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
throw new HSAdminException("domain admin required");
|
||||
}
|
||||
if (!admin.getName().equals(oldDom.getUser().getName())) {
|
||||
// TODO should be implemented later
|
||||
throw new AuthorisationException(loginUser, "update", existingEntity, "user");
|
||||
// Sollte in Zukunft erlaubt werden.
|
||||
}
|
||||
Query q = em.createQuery("SELECT opt FROM " +
|
||||
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
||||
|
@ -74,10 +74,30 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
}
|
||||
|
||||
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) throws ProcessorException {
|
||||
return new ShellProcessor("echo \"hello\"");
|
||||
Domain dom = (Domain) entity;
|
||||
UnixUser domUser = dom.getUser();
|
||||
Pac pac = domUser.getPac();
|
||||
String pacName = pac.getName();
|
||||
String domName = dom.getName();
|
||||
Map<String, String> templateVars = new HashMap<String, String>();
|
||||
templateVars.put("PAC", pacName);
|
||||
templateVars.put("HIVE", pac.getHiveName());
|
||||
templateVars.put("DOM_HOSTNAME", domName);
|
||||
templateVars.put("DOM_USERNAME", domUser.getName());
|
||||
templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
|
||||
templateVars.put("DOM_IPNUMBER", getCurrentIPAddress(pac));
|
||||
templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
|
||||
templateVars.put("DOMAIN", domName);
|
||||
templateVars.put("USER_NAME", domUser.getComment());
|
||||
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");
|
||||
}
|
||||
return processor;
|
||||
}
|
||||
|
||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
|
||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
|
||||
Domain dom = (Domain) entity;
|
||||
String domName = dom.getName();
|
||||
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
|
||||
@ -92,6 +112,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
}
|
||||
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(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
|
||||
return mainProcessor;
|
||||
@ -164,6 +185,18 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
}
|
||||
|
||||
private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException {
|
||||
return 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:[" + pac.getName() + ".hostsharing.net]\n" +
|
||||
"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n")
|
||||
);
|
||||
}
|
||||
|
||||
private Processor createPostgreyConfiguration(EntityManager em) throws ProcessorException {
|
||||
ArrayList<Map<String, String>> domsMaps = new ArrayList<Map<String, String>>();
|
||||
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option");
|
||||
query.setParameter("option", "nogreylisting");
|
||||
@ -178,14 +211,9 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
return new CompoundProcessor(
|
||||
new TemplateProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl",
|
||||
new HashMap<String, String>(),
|
||||
domsMaps.iterator(), "/etc/postgrey/whitelist_recipients", true),
|
||||
new ShellProcessor("invoke-rc.d postgrey reload"),
|
||||
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:[" + pac.getName() + ".hostsharing.net]\n" +
|
||||
"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n")
|
||||
domsMaps.iterator(), "/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 )")
|
||||
);
|
||||
}
|
||||
|
||||
@ -283,14 +311,17 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
}
|
||||
Processor domSetupProcessor = new CompoundProcessor(
|
||||
createDomainDirectoriesProcessor(dom, templateVars),
|
||||
new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName, "root", "root", "644", true),
|
||||
new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
|
||||
new ShellProcessor("ls /etc/apache2/pems/" + pac + ".pem >/dev/null 2>&1 " +
|
||||
"&& sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName +
|
||||
"&& sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName + ".tmp" +
|
||||
" && (ls /etc/apache2/pems/" + pac + ".chain.pem >/dev/null 2>&1 || sed -i '/SSLCertificateChain.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ")" +
|
||||
" || sed -i '/SSLCertificate.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName),
|
||||
" || sed -i '/SSLCertificate.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ".tmp"),
|
||||
new ShellProcessor(
|
||||
"ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||
" && invoke-rc.d apache2 reload >/dev/null 2>&1")
|
||||
" ( diff -q /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName + " && rm /etc/apache2/sites-available/" + domName + ".tmp ) " +
|
||||
" || ( mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName +
|
||||
" && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||
" && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||
" && invoke-rc.d apache2 reload >/dev/null 2>&1 ) ")
|
||||
);
|
||||
return domSetupProcessor;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user