dont create pac domain
This commit is contained in:
parent
4f863a4cc2
commit
97bfe29c61
@ -33,6 +33,17 @@ public class VelocityProcessor extends AbstractProcessor {
|
|||||||
private boolean overwriteTarget;
|
private boolean overwriteTarget;
|
||||||
private String errorMessage;
|
private String errorMessage;
|
||||||
|
|
||||||
|
public VelocityProcessor(String templateName, Map<String, Object> templateVars, String targetPath, boolean overwriteTarget) {
|
||||||
|
errorMessage = "";
|
||||||
|
this.targetPath = targetPath;
|
||||||
|
this.overwriteTarget = overwriteTarget;
|
||||||
|
VelocityContext context = new VelocityContext();
|
||||||
|
for (String key : templateVars.keySet()) {
|
||||||
|
context.put(key, templateVars.get(key));
|
||||||
|
}
|
||||||
|
mergeTemplate(templateName, context);
|
||||||
|
}
|
||||||
|
|
||||||
public VelocityProcessor(String templateName, Hive hive, String targetPath, boolean overwriteTarget) {
|
public VelocityProcessor(String templateName, Hive hive, String targetPath, boolean overwriteTarget) {
|
||||||
errorMessage = "";
|
errorMessage = "";
|
||||||
this.targetPath = targetPath;
|
this.targetPath = targetPath;
|
||||||
|
@ -19,7 +19,6 @@ import de.hsadmin.core.util.TextUtil;
|
|||||||
import de.hsadmin.hostsharing.BasePacType;
|
import de.hsadmin.hostsharing.BasePacType;
|
||||||
import de.hsadmin.mods.cust.Contact;
|
import de.hsadmin.mods.cust.Contact;
|
||||||
import de.hsadmin.mods.cust.Customer;
|
import de.hsadmin.mods.cust.Customer;
|
||||||
import de.hsadmin.mods.dom.Domain;
|
|
||||||
import de.hsadmin.mods.user.UnixUser;
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
public class PacModuleImpl extends AbstractModuleImpl {
|
public class PacModuleImpl extends AbstractModuleImpl {
|
||||||
@ -113,11 +112,6 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
|||||||
admin.setUserId(nUID);
|
admin.setUserId(nUID);
|
||||||
users.add(admin);
|
users.add(admin);
|
||||||
newPacEntity = super.add(newEntity);
|
newPacEntity = super.add(newEntity);
|
||||||
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
|
|
||||||
Domain pacDomain = new Domain();
|
|
||||||
pacDomain.setName(pac.getName() + ".hostsharing.net");
|
|
||||||
pacDomain.setUser(admin);
|
|
||||||
helperModule.add(pacDomain);
|
|
||||||
} else {
|
} else {
|
||||||
newPacEntity = super.add(newEntity);
|
newPacEntity = super.add(newEntity);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package de.hsadmin.mods.pac;
|
package de.hsadmin.mods.pac;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
|
||||||
import de.hsadmin.core.model.AbstractEntity;
|
import de.hsadmin.core.model.AbstractEntity;
|
||||||
import de.hsadmin.core.qserv.CompoundProcessor;
|
import de.hsadmin.core.qserv.CompoundProcessor;
|
||||||
@ -17,6 +22,7 @@ import de.hsadmin.core.qserv.WaitingTasksProcessor;
|
|||||||
import de.hsadmin.core.util.PasswordTool;
|
import de.hsadmin.core.util.PasswordTool;
|
||||||
import de.hsadmin.hostsharing.BasePacType;
|
import de.hsadmin.hostsharing.BasePacType;
|
||||||
import de.hsadmin.hostsharing.QuotaLimit;
|
import de.hsadmin.hostsharing.QuotaLimit;
|
||||||
|
import de.hsadmin.mods.dom.Domain;
|
||||||
import de.hsadmin.mods.user.UnixUser;
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
|
|
||||||
@ -38,6 +44,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
createEtcHostsProc(hive),
|
createEtcHostsProc(hive),
|
||||||
createNetworkInterfacesProc(hive),
|
createNetworkInterfacesProc(hive),
|
||||||
createIPTablesProc(),
|
createIPTablesProc(),
|
||||||
|
createZonefileProc(em, pac),
|
||||||
createSudouersProc(hive),
|
createSudouersProc(hive),
|
||||||
createProftpdConfProc(hive),
|
createProftpdConfProc(hive),
|
||||||
createMakePacDirectoryStructure(unixUser),
|
createMakePacDirectoryStructure(unixUser),
|
||||||
@ -130,6 +137,46 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
return new ShellProcessor("mk-iptables-rules Accounting");
|
return new ShellProcessor("mk-iptables-rules Accounting");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Processor createZonefileProc(final EntityManager em, final Pac pac) {
|
||||||
|
final Map<String, Object> zonefileTemplateVars = new HashMap<String, Object>();
|
||||||
|
zonefileTemplateVars.put("sio", Long.toString(System.currentTimeMillis()/1000L));
|
||||||
|
final String domName = pac.getName() + ".hostsharing.net";
|
||||||
|
final String zonefileTargetPath = "/etc/bind/pri." + domName;
|
||||||
|
final Processor zonefileTemplateProcessor =
|
||||||
|
new VelocityProcessor("/de/hsadmin/mods/pac/pac-zonefile.vm", zonefileTemplateVars, zonefileTargetPath, false);
|
||||||
|
final Processor zonefileACLProcessor =
|
||||||
|
new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath);
|
||||||
|
final String hiveName = pac.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", domsNames);
|
||||||
|
final Processor prizonesFileProcessor = new CompoundProcessor(
|
||||||
|
new VelocityProcessor("/de/hsadmin/mods/dom/named-pri-zones.vm",
|
||||||
|
namedZonesTemplateVars, "/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 )")
|
||||||
|
);
|
||||||
|
final Processor dnsSetupProcessor =
|
||||||
|
new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor);
|
||||||
|
return dnsSetupProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
private Processor createSudouersProc(Hive hive) throws ProcessorException {
|
private Processor createSudouersProc(Hive hive) throws ProcessorException {
|
||||||
return new VelocityProcessor("/de/hsadmin/mods/pac/sudoers-pacs.vm", hive, "/etc/sudoers.d/pacs", true);
|
return new VelocityProcessor("/de/hsadmin/mods/pac/sudoers-pacs.vm", hive, "/etc/sudoers.d/pacs", true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user