From a759d312fc4805d76e762a0980b8d6e379fcb049 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Tue, 03 Dec 2019 19:48:32 +0100
Subject: [PATCH] add autoconfig to validsubdomais if needed

---
 hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
index 2cb9038..8242798 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -410,7 +410,24 @@
 		final Map<String, Object> templateVars = new HashMap<String, Object>();
 		query.setParameter("hivename", hiveName);
 		query.setParameter("option", "letsencrypt");		
-		templateVars.put("domains", query.getResultList());
+		final List<?> domainsResultList = query.getResultList();
+		for (Object domObj : domainsResultList) {
+			if (domObj instanceof Domain) {
+				final Domain d = (Domain) domObj;
+				boolean autoconfig = false;
+				final Set<DomainOption> domainoptions = d.getDomainoptions();
+				for (DomainOption opt : domainoptions) {
+					if ("autoconfig".equals(opt.getName())) {
+						autoconfig = true;
+					}
+				}
+				final String validSubdomains = d.getValidsubdomainnames();
+				if (autoconfig && !validSubdomains.contains("autoconfig")) {
+					d.setValidsubdomainnames(validSubdomains + ",autoconfig");
+				}
+			}
+		}
+		templateVars.put("domains", domainsResultList);
 		return new CompoundProcessor(
 				new CreateFileProcessor("/de/hsadmin/mods/dom/acmebot-domain.properties.vm", templateVars, dom,
 						"/etc/hostsharing/acmebot/domain.properties.tmp", "acmebot", "acmebot", "640", true),

--
Gitblit v1.9.0-SNAPSHOT