HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2013-03-06 e6fb369f8873e43bec9f81785c797fd9cd238999
clean imports
2 files modified
1 files added
39 ■■■■ changed files
hsarback/src/de/hsadmin/mods/cust/Customer.java 1 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 30 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/named-hsh-conf.vm 8 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/cust/Customer.java
@@ -23,7 +23,6 @@
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -43,7 +43,7 @@
        mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, dom), "Setup EMail");
        Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.dns").split(",")) {
            mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(dom.getName(), pac.getHive().getInetAddr().getInetAddr()), queueName + ".hostsharing.net");
            mainProcessor.appendProcessor(queueName, createDNSServerConfigProcessor(em), queueName + ".hostsharing.net");
        }
        for (String queueName : config.getProperty("queues.mail").split(",")) {
            mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
@@ -73,7 +73,7 @@
            );
        Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.dns").split(",")) {
            mainProcessor.appendProcessor(queueName, createDNSServerRemoveProcessor(domName), queueName + ".hostsharing.net");
            mainProcessor.appendProcessor(queueName, createDNSServerConfigProcessor(em), queueName + ".hostsharing.net");
        }
        for (String queueName : config.getProperty("queues.mail").split(",")) {
            mainProcessor.appendProcessor(queueName, createMailinUnsetupProcessor(em, dom), queueName + ".hostsharing.net");
@@ -124,22 +124,16 @@
        return emailAdrProcessor;
    }
    private Processor createDNSServerSetupProcessor(String domName, String hiveInetAddr) {
        Processor seczonesFileProcessor;
        seczonesFileProcessor =
            new ShellProcessor("echo 'zone \"" + domName + "\" { type slave; file \"sec." + domName + "\"; masters { " + hiveInetAddr + "; }; };' >>/etc/bind/named-hsh.conf" +
                " && sort /etc/bind/named-hsh.conf | uniq >/etc/bind/named-hsh.conf.tmp" +
                " && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" +
                " && invoke-rc.d bind9 reload");
        return seczonesFileProcessor;
    }
    private Processor createDNSServerRemoveProcessor(String domName) {
        // TODO Use templates and regenerate the file.
        return new ShellProcessor("grep -v '\"sec." + domName + "\"' /etc/bind/named-hsh.conf >/etc/bind/named-hsh.conf.tmp" +
                " && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" +
                " && rm /var/cache/bind/sec." + domName +
                " && invoke-rc.d bind9 reload");
    private Processor createDNSServerConfigProcessor(EntityManager em) {
        Query query = em.createQuery("SELECT d FROM Domains d");
        HashMap<String, Object> templateVars = new HashMap<String, Object>();
        templateVars.put("domains", query.getResultList());
        return new CompoundProcessor(
            new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
                        templateVars, "/etc/bind/named-hsh.conf.tmp", true),
            new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
                    "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
        );
    }
    private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
hsarback/src/de/hsadmin/mods/dom/named-hsh-conf.vm
New file
@@ -0,0 +1,8 @@
//
// This file is managed by HSAdmin.
// Do not edit manually. Changes will be overwritten.
//
#foreach( $domain in ${domains} )
zone "${domain.name}" { type slave; file "sec.${domain.name}"; masters { ${domain.user.pac.hive.inetaddr}; }; };
#end