maintain named-pri-zones
This commit is contained in:
parent
fb7e714e63
commit
4f863a4cc2
@ -2,8 +2,10 @@ package de.hsadmin.mods.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
@ -106,10 +108,26 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
new VelocityProcessor("/de/hsadmin/mods/dom/zonefile.vm", zonefileTemplateVars, dom, zonefileTargetPath, false);
|
||||
final Processor zonefileACLProcessor =
|
||||
new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath);
|
||||
final Query query = em.createQuery("SELECT d FROM Domains d WHERE d.user.pac.hive.name = :hivename");
|
||||
query.setParameter("hivename", dom.getUser().getHiveName());
|
||||
final String hiveName = dom.getUser().getHiveName();
|
||||
final Query domsQuery = em.createQuery("SELECT d FROM Domains d WHERE d.user.pac.hive.name = :hivename");
|
||||
domsQuery.setParameter("hivename", hiveName);
|
||||
final List<?> domsList = domsQuery.getResultList();
|
||||
final Set<String> domsNames = new HashSet<>();
|
||||
for (final Object obj : domsList) {
|
||||
if (obj instanceof Domain) {
|
||||
domsNames.add(((Domain) obj).getName());
|
||||
}
|
||||
}
|
||||
final Query pacsQuery = em.createQuery("SELECT p FROM Pacs p WHERE p.hive.name = :hivename");
|
||||
domsQuery.setParameter("hivename", hiveName);
|
||||
final List<?> pacsList = pacsQuery.getResultList();
|
||||
for (final Object obj : pacsList) {
|
||||
if (obj instanceof Pac) {
|
||||
domsNames.add(((Pac) obj).getName() + ".hostsharing.net");
|
||||
}
|
||||
}
|
||||
final Map<String, Object> namedZonesTemplateVars = new HashMap<String, Object>();
|
||||
namedZonesTemplateVars.put("domains", query.getResultList());
|
||||
namedZonesTemplateVars.put("domains", domsNames);
|
||||
final Processor prizonesFileProcessor = new CompoundProcessor(
|
||||
new VelocityProcessor("/de/hsadmin/mods/dom/named-pri-zones.vm",
|
||||
namedZonesTemplateVars, dom, "/etc/bind/named.pri-zones.tmp", true),
|
||||
@ -124,7 +142,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
private ShellProcessor createHiveDNSRemoveProcessor(String domName) {
|
||||
return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" +
|
||||
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
||||
" && rm /etc/bind/pri." + domName +
|
||||
" && rm -f /etc/bind/pri." + domName +
|
||||
" && invoke-rc.d bind9 reload");
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@
|
||||
//
|
||||
|
||||
#foreach( $domain in ${domains} )
|
||||
zone "${domain.name}" { type master; file "pri.${domain.name}"; };
|
||||
zone "${domain}" { type master; file "pri.${domain}"; };
|
||||
#end
|
||||
|
@ -76,6 +76,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
Hive hive = pac.getHive();
|
||||
hive.getPacs().remove(pac);
|
||||
WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
|
||||
final String domainName = pac.getName() + ".hostsharing.net";
|
||||
waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(
|
||||
createIfDown(pac),
|
||||
createEtcHostsProc(hive),
|
||||
@ -83,6 +84,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
createSudouersProc(hive),
|
||||
createProftpdConfProc(hive),
|
||||
createHttpdVirtualProc(hive),
|
||||
createHiveDNSRemoveProcessor(domainName),
|
||||
createAccountingRulesProc()), "remove packet");
|
||||
return waiting;
|
||||
} else {
|
||||
@ -90,6 +92,13 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private ShellProcessor createHiveDNSRemoveProcessor(String domName) {
|
||||
return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" +
|
||||
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
||||
" && rm -f /etc/bind/pri." + domName +
|
||||
" && invoke-rc.d bind9 reload");
|
||||
}
|
||||
|
||||
private Processor createAccountingRulesProc() {
|
||||
return new ShellProcessor("mk-iptables-rules Accounting");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user