From b137b45b381f04903e72b255d62b5a794cf0f4bb Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Mon, 29 Jul 2019 18:07:08 +0200
Subject: [PATCH] fix list of all dns zones

---
 hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
index ba69558..fc1aeb8 100644
--- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -1,5 +1,6 @@
 package de.hsadmin.mods.pac;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -50,6 +51,7 @@
 				createMakePacDirectoryStructure(unixUser),
 				createIfUp(pac),
 				createHttpdVirtualProc(hive),
+				createDNSServerConfigProcessor(em),
 				createAccountingRulesProc());
 		} else {
 			return new NullProcessor();
@@ -279,6 +281,31 @@
 		);
 	}
 
+	private Processor createDNSServerConfigProcessor(EntityManager em) {
+		final HashMap<String, Object> templateVars = new HashMap<String, Object>();
+		final Query pacsQuery = em.createQuery("SELECT p FROM Pacs p WHERE p.basepac.name = 'PAC/WEB'");
+		final List<?> pacsList = pacsQuery.getResultList();
+		templateVars.put("pacs", pacsList);
+		final Query domsQuery = em.createQuery("SELECT d FROM Domains d");		
+		final List<?> domsList = domsQuery.getResultList();
+		final List<Domain> filteredDomsList = new ArrayList<Domain>();
+		for (final Object listElement : domsList) {
+			if (listElement instanceof Domain) {
+				final Domain d = (Domain) listElement;
+				if (!d.isPacDomain()) {
+					filteredDomsList.add(d);
+				}
+			}
+		}
+		templateVars.put("domains", filteredDomsList);
+		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 UnixUser getPacAdminUser(Pac pac) throws ProcessorException {
 		UnixUser unixUser = null;
 		Set<UnixUser> unixUserSet = pac.getUnixUser();

--
Gitblit v1.9.0-SNAPSHOT