Migrated DNS secodaries configuration to velocity.
This commit is contained in:
parent
1816c4fc61
commit
f024759495
@ -43,7 +43,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
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 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
);
|
||||
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 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
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 {
|
||||
|
8
hsarback/src/de/hsadmin/mods/dom/named-hsh-conf.vm
Normal file
8
hsarback/src/de/hsadmin/mods/dom/named-hsh-conf.vm
Normal 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
|
Loading…
Reference in New Issue
Block a user