| | |
| | | Domain dom = (Domain) entity; |
| | | UnixUser domUser = dom.getUser(); |
| | | Pac pac = domUser.getPac(); |
| | | WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(dom)); |
| | | WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(em, dom)); |
| | | mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, dom), "Setup EMail"); |
| | | Config config = Config.getInstance(); |
| | | for (String queueName : config.getProperty("queues.dns").split(",")) { |
| | |
| | | return mainProcessor; |
| | | } |
| | | |
| | | private Processor createHiveDNSSetupProcessor(Domain dom) throws ProcessorException { |
| | | 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 createHiveDNSSetupProcessor(EntityManager em, Domain dom) throws ProcessorException { |
| | | Map<String, Object> templateVars = new HashMap<String, Object>(); |
| | | templateVars.put("sio", Long.toString(System.currentTimeMillis()/1000L)); |
| | | String domName = dom.getName(); |
| | |
| | | new VelocityProcessor("/de/hsadmin/mods/dom/zonefile.vm", templateVars, dom, zonefileTargetPath, false); |
| | | Processor zonefileACLProcessor = |
| | | new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath); |
| | | // TODO Use templates and regenerate the file. |
| | | Processor prizonesFileProcessor = |
| | | new ShellProcessor("echo 'zone \"" + domName + "\" { type master; file \"pri." + domName + "\"; };' >>/etc/bind/named.pri-zones" + |
| | | " && sort /etc/bind/named.pri-zones | uniq >/etc/bind/named.pri-zones.tmp" + |
| | | " && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones"); |
| | | Processor dnsReloadProcessor = new ShellProcessor("invoke-rc.d bind9 reload"); |
| | | Query query = em.createQuery("SELECT d FROM Domains d WHERE d.user.pac.hive.name = :hivename"); |
| | | query.setParameter("hivename", dom.getUser().getHiveName()); |
| | | templateVars = new HashMap<String, Object>(); |
| | | templateVars.put("domains", query.getResultList()); |
| | | Processor prizonesFileProcessor = new CompoundProcessor( |
| | | new VelocityProcessor("/de/hsadmin/mods/dom/named-pri-zones.vm", |
| | | templateVars, dom, "/etc/bind/named.pri-zones.tmp", true), |
| | | new ShellProcessor(" ( diff -q /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones && rm /etc/bind/named.pri-zones.tmp ) " + |
| | | "|| ( mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones && invoke-rc.d bind9 reload )") |
| | | ); |
| | | Processor dnsSetupProcessor = |
| | | new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor, dnsReloadProcessor); |
| | | new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor); |
| | | return dnsSetupProcessor; |
| | | } |
| | | |
| | |
| | | emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress)); |
| | | } |
| | | return emailAdrProcessor; |
| | | } |
| | | |
| | | 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 { |