HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2013-02-20 6208e0ec8cb312e814f80a26d515a945fea71258
use velocity template engine
7 files modified
4 files renamed
9 files added
12 files deleted
1583 ■■■■■ changed files
hsarback/.classpath 1 ●●●● patch | view | raw | blame | history
hsarback/build.xml 4 ●●●● patch | view | raw | blame | history
hsarback/lib/velocity-1.7.jar patch | view | raw | blame | history
hsarback/src/de/hsadmin/core/qserv/CreateFileProcessor.java 14 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/core/qserv/MailerProcessor.java 56 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/core/qserv/TemplateProcessor.java 81 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/core/qserv/VelocityProcessor.java 144 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 179 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/htaccess.jtpl 2 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/htaccess.vm 1 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl 106 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl 90 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm 145 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/index.html.jtpl 22 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/index.html.vm 21 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm 8 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/test.cgi.jtpl 5 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/test.cgi.vm 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/zonefile.jtpl 25 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/zonefile.vm 24 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/BasePac.java 1 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/Hive.java 6 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java 92 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/hosts.vm 10 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl 12 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm 11 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/interfaces.jtpl 22 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/interfaces.vm 22 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/proftpd-conf.vm 24 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/sudoers.vm 8 ●●●● patch | view | raw | blame | history
hsarback/src/net/sf/jtpl/Jtpl.java 307 ●●●●● patch | view | raw | blame | history
hsarback/src/net/sf/jtpl/Template.java 136 ●●●●● patch | view | raw | blame | history
hsarback/.classpath
@@ -28,5 +28,6 @@
    <classpathentry kind="lib" path="lib/xmlrpc-common-3.1.3.jar"/>
    <classpathentry kind="lib" path="lib/xmlrpc-server-3.1.3.jar"/>
    <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    <classpathentry kind="lib" path="lib/velocity-1.7.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
hsarback/build.xml
@@ -47,7 +47,7 @@
            <fileset dir="build/cls"/>
            <fileset dir="src">
                <include name="**/*.properties"/>
                <include name="**/*.jtpl"/>
                <include name="**/*.vm"/>
            </fileset>
            <fileset dir="conf">
                <include name="**/*.xml"/>
@@ -77,7 +77,7 @@
            <classes dir="build/cls" />
            <classes dir="src">
                <include name="**/*.properties"/>
                <include name="**/*.jtpl"/>
                <include name="**/*.vm"/>
            </classes>
            <classes dir="conf">
                <include name="**/*.xml"/>
hsarback/lib/velocity-1.7.jar
Binary files differ
hsarback/src/de/hsadmin/core/qserv/CreateFileProcessor.java
@@ -1,7 +1,9 @@
package de.hsadmin.core.qserv;
import java.util.Iterator;
import java.util.Map;
import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.pac.Hive;
public class CreateFileProcessor extends AbstractProcessor {
@@ -9,18 +11,18 @@
    private Processor compoundProcessor;
    
    public CreateFileProcessor(String templateName, Map<String, String> templateValues, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
        TemplateProcessor templateProcessor = new TemplateProcessor(templateName, templateValues, targetPath, overwriteTarget);
    public CreateFileProcessor(String templateName, Map<String, Object> templateValues, Domain dom, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
        VelocityProcessor templateProcessor = new VelocityProcessor(templateName, templateValues, dom, targetPath, overwriteTarget);
        compoundProcessor = createCompound(targetPath, owner, group, modeMask, templateProcessor);
    }
    public CreateFileProcessor(String templateName, Map<String, String> templateValues, Iterator<Map<String, String>> iterateValues, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
        TemplateProcessor templateProcessor = new TemplateProcessor(templateName, templateValues, iterateValues, targetPath, overwriteTarget);
    public CreateFileProcessor(String templateName, Hive hive, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
        VelocityProcessor templateProcessor = new VelocityProcessor(templateName, hive, targetPath, overwriteTarget);
        compoundProcessor = createCompound(targetPath, owner, group, modeMask, templateProcessor);
    }
    private Processor createCompound(String targetPath, String owner, String group,
            String modeMask, TemplateProcessor templateProcessor) {
            String modeMask, Processor templateProcessor) {
        ShellProcessor shellProcessor = 
            new ShellProcessor(
                "chown " + owner + ":" + group + " " + targetPath + " && " +
hsarback/src/de/hsadmin/core/qserv/MailerProcessor.java
File was deleted
hsarback/src/de/hsadmin/core/qserv/TemplateProcessor.java
File was deleted
hsarback/src/de/hsadmin/core/qserv/VelocityProcessor.java
New file
@@ -0,0 +1,144 @@
package de.hsadmin.core.qserv;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang.CharEncoding;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.pac.BasePac;
import de.hsadmin.mods.pac.Hive;
import de.hsadmin.mods.pac.INetAddress;
import de.hsadmin.mods.pac.Pac;
public class VelocityProcessor extends AbstractProcessor {
    private static final long serialVersionUID = 1L;
    static {
        Properties props = new Properties();
        props.getProperty("resource.loader", "file");
        props.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        Velocity.init(props);
    }
    private String content;
    private String targetPath;
    private boolean overwriteTarget;
    public VelocityProcessor(String templateName, Hive hive, String targetPath, boolean overwriteTarget) {
        this.targetPath = targetPath;
        this.overwriteTarget = overwriteTarget;
        VelocityContext context = new VelocityContext();
        context.put("hive", hive);
        mergeTemplate(templateName, context);
    }
    public VelocityProcessor(String templateName, Pac pac, String targetPath, boolean overwriteTarget) {
        this.targetPath = targetPath;
        this.overwriteTarget = overwriteTarget;
        VelocityContext context = new VelocityContext();
        context.put("pac", pac);
        context.put("hive", pac.getHive());
        mergeTemplate(templateName, context);
    }
    public VelocityProcessor(String templateName, Domain dom, String targetPath, boolean overwriteTarget) {
        this.targetPath = targetPath;
        this.overwriteTarget = overwriteTarget;
        VelocityContext context = new VelocityContext();
        context.put("dom", dom);
        Pac pac = dom.getUser().getPac();
        context.put("pac", pac);
        context.put("hive", pac.getHive());
        mergeTemplate(templateName, context);
    }
    public VelocityProcessor(String templateName, Map<String, Object> templateVars, Domain dom, String targetPath, boolean overwriteTarget) {
        this.targetPath = targetPath;
        this.overwriteTarget = overwriteTarget;
        VelocityContext context = new VelocityContext();
        context.put("dom", dom);
        Pac pac = dom.getUser().getPac();
        context.put("pac", pac);
        context.put("hive", pac.getHive());
        for (String key : templateVars.keySet()) {
            context.put(key, templateVars.get(key));
        }
        mergeTemplate(templateName, context);
    }
    public VelocityProcessor(String templateName, HashMap<String, Object> templateVars,
            String targetPath, boolean overwriteTarget) {
        this.targetPath = targetPath;
        this.overwriteTarget = overwriteTarget;
        VelocityContext context = new VelocityContext();
        for (String key : templateVars.keySet()) {
            context.put(key, templateVars.get(key));
        }
        mergeTemplate(templateName, context);
    }
    private void mergeTemplate(String templateName, VelocityContext context) {
        StringWriter writer = new StringWriter();
        Velocity.mergeTemplate(templateName, CharEncoding.UTF_8, context, writer);
        this.content = writer.toString();
    }
    @Override
    public Object process() throws ProcessorException {
        try {
            File file = new File(targetPath);
            if (file.exists() && !overwriteTarget) {
                return "did not overwrite existing file " + targetPath;
            }
            if (!file.exists() || file.canWrite()) {
                BufferedWriter writer = new BufferedWriter(new FileWriter(file));
                writer.append(content);
                writer.close();
            } else {
                throw new ProcessorException("could not write file " + targetPath);
            }
            return "wrote file " + targetPath;
        } catch (IOException e) {
            throw new ProcessorException(e);
        }
    }
    public static void main(String[] args) {
        Hive h = new Hive("h01", new INetAddress("192.168.1.100"));
        HashSet<Pac> pacsSet = new HashSet<Pac>();
        h.setPacs(pacsSet);
        Pac p1 = new Pac("pac01", null, new BasePac(), h);
        pacsSet.add(p1);
        Pac p2 = new Pac("pac02", null, new BasePac(), h);
        pacsSet.add(p2);
        p1.setCurINetAddr(new INetAddress("192.168.2.11"));
        p2.setCurINetAddr(new INetAddress("192.168.2.12"));
        VelocityProcessor procHosts = new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", h, "/tmp/etc-hosts", true);
        VelocityProcessor procVirtual = new VelocityProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", h, "/tmp/httpd-virtual.conf", true);
        VelocityProcessor procInterfaces = new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", h, "/tmp/net-interfaces", true);
        VelocityProcessor procProFtpd = new VelocityProcessor("/de/hsadmin/mods/pac/proftpd-conf.vm", h, "/tmp/proftpd.conf", true);
        VelocityProcessor procSudoers = new VelocityProcessor("/de/hsadmin/mods/pac/sudoers.vm", h, "/tmp/sudoers", true);
        try {
            System.out.println(procHosts.process());
            System.out.println(procVirtual.process());
            System.out.println(procInterfaces.process());
            System.out.println(procProFtpd.process());
            System.out.println(procSudoers.process());
        } catch (ProcessorException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -16,12 +16,11 @@
import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.ProcessorException;
import de.hsadmin.core.qserv.ShellProcessor;
import de.hsadmin.core.qserv.TemplateProcessor;
import de.hsadmin.core.qserv.VelocityProcessor;
import de.hsadmin.core.qserv.WaitingTasksProcessor;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.email.EMailAddress;
import de.hsadmin.mods.email.EMailAddressProcessorFactory;
import de.hsadmin.mods.pac.INetAddress;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@@ -40,39 +39,17 @@
        Domain dom = (Domain) entity;
        UnixUser domUser = dom.getUser();
        Pac pac = domUser.getPac();
        String pacName = pac.getName();
        String domName = dom.getName();
        Map<String, String> templateVars = new HashMap<String, String>();
        templateVars.put("SIO", Long.toString(System.currentTimeMillis()/1000L));
        templateVars.put("PAC", pacName);
        templateVars.put("HIVE", pac.getHiveName());
        templateVars.put("DOM_HOSTNAME", domName);
        templateVars.put("DOM_USERNAME", domUser.getName());
        templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
        templateVars.put("DOM_IPNUMBER", getCurrentIPAddress(pac));
        templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
        WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(domName, templateVars));
        mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, domName), "Setup EMail");
        String hiveInetAddr = pac.getHive().getInetAddr().getInetAddr();
        WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(dom));
        mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, dom), "Setup EMail");
        Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.dns").split(",")) {
            mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net");
            mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(dom.getName(), pac.getHive().getInetAddr().getInetAddr()), queueName + ".hostsharing.net");
        }
        for (String queueName : config.getProperty("queues.mail").split(",")) {
            mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
        }
        templateVars = new HashMap<String, String>();
        templateVars.put("PAC", pacName);
        templateVars.put("HIVE", pac.getHiveName());
        templateVars.put("DOM_HOSTNAME", domName);
        templateVars.put("DOM_USERNAME", domUser.getName());
        templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
        templateVars.put("DOM_IPNUMBER", getCurrentIPAddress(pac));
        templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
        templateVars.put("DOMAIN", domName);
        templateVars.put("USER_NAME", domUser.getComment());
        mainProcessor.appendProcessor(hiveName, createDomainDirectoriesProcessor(dom, templateVars), "Setup Domain Directories");
        mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom, templateVars), "Setup Apache VHost");
        mainProcessor.appendProcessor(hiveName, createDomainDirectoriesProcessor(dom), "Setup Domain Directories");
        mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom), "Setup Apache VHost");
        return mainProcessor;
    }
@@ -80,19 +57,7 @@
        Domain dom = (Domain) entity;
        UnixUser domUser = dom.getUser();
        Pac pac = domUser.getPac();
        String pacName = pac.getName();
        String domName = dom.getName();
        Map<String, String> templateVars = new HashMap<String, String>();
        templateVars.put("PAC", pacName);
        templateVars.put("HIVE", pac.getHiveName());
        templateVars.put("DOM_HOSTNAME", domName);
        templateVars.put("DOM_USERNAME", domUser.getName());
        templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
        templateVars.put("DOM_IPNUMBER", getCurrentIPAddress(pac));
        templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
        templateVars.put("DOMAIN", domName);
        templateVars.put("USER_NAME", domUser.getComment());
        WaitingTasksProcessor processor = new WaitingTasksProcessor(createApacheVHostSetupProcessor(em, dom, templateVars));
        WaitingTasksProcessor processor = new WaitingTasksProcessor(createApacheVHostSetupProcessor(em, dom));
        Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.mail").split(",")) {
            processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
@@ -117,11 +82,13 @@
        return mainProcessor;
    }
    private Processor createHiveDNSSetupProcessor(String domName, Map<String, String> templateVars)
            throws ProcessorException {
    private Processor createHiveDNSSetupProcessor(Domain dom) throws ProcessorException {
        Map<String, Object> templateVars = new HashMap<String, Object>();
        templateVars.put("sio", Long.toString(System.currentTimeMillis()/1000L));
        String domName = dom.getName();
        String zonefileTargetPath = "/etc/bind/pri." + domName;
        Processor zonefileTemplateProcessor = 
            new TemplateProcessor("/de/hsadmin/mods/dom/zonefile.jtpl", templateVars, zonefileTargetPath, false);
            new VelocityProcessor("/de/hsadmin/mods/dom/zonefile.vm", templateVars, dom, zonefileTargetPath, false);
        Processor zonefileACLProcessor = 
            new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath);
        // TODO Use templates and regenerate the file.
@@ -142,13 +109,13 @@
            " && invoke-rc.d bind9 reload");
    }
    private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, String domName) {
    private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, Domain dom) {
        EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory();
        CompoundProcessor emailAdrProcessor = new CompoundProcessor();
        Query query = em.createQuery(
            "SELECT adr FROM " + 
                EMailAddress.class.getAnnotation(javax.persistence.Entity.class).name() + " adr " +
                "WHERE adr.domain.name='" + domName + "'");
                "WHERE adr.domain.name='" + dom.getName() + "'");
        List<?> resultList = query.getResultList();
        for (Object obj : resultList) {
            EMailAddress eMailAddress = (EMailAddress) obj;
@@ -202,7 +169,7 @@
    }
    
    private Processor createPostgreyConfiguration(EntityManager em) throws ProcessorException {
        ArrayList<Map<String, String>> domsMaps = new ArrayList<Map<String, String>>();
        List<Domain> whitelistDoms = new ArrayList<Domain>();
        Query query = em.createQuery("SELECT DISTINCT dom FROM Domains dom WHERE NOT EXISTS " +
            "( SELECT postgreyDom FROM Domains postgreyDom " +
            "   WHERE postgreyDom.domainoptions.name = :option" +
@@ -211,15 +178,14 @@
        List<?> result = query.getResultList();
        for (Object dom : result) {
            if (dom instanceof Domain) {
                HashMap<String, String> hashMap = new HashMap<String, String>();
                hashMap.put("DOM", ((Domain) dom).getName());
                domsMaps.add(hashMap);
                whitelistDoms.add((Domain) dom);
            }
        }
        HashMap<String, Object> templateVars = new HashMap<String, Object>();
        templateVars.put("whitelist", whitelistDoms);
        return new CompoundProcessor(
            new TemplateProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl",
                        new HashMap<String, String>(),
                        domsMaps.iterator(), "/etc/postgrey/whitelist_recipients.tmp", true),
            new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm",
                        templateVars, "/etc/postgrey/whitelist_recipients.tmp", true),
            new ShellProcessor(" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) " +
                    "|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )")
        );
@@ -236,7 +202,8 @@
        return mailQueueProcessor;
    }
    private CompoundProcessor createDomainDirectoriesProcessor(Domain dom, Map<String, String> templateVars) throws ProcessorException {
    private CompoundProcessor createDomainDirectoriesProcessor(Domain dom) throws ProcessorException {
        Map<String, Object> templateVars = new HashMap<String, Object>();
        UnixUser domUser = dom.getUser();
        String domName = dom.getName();
        Pac pac = domUser.getPac();
@@ -269,26 +236,26 @@
                    "chown " + userName + ":" + pacName +  " " + domainDir + "/" + subDir
                ));
        }
        templateVars.put("PROTOCOL", "http");
        templateVars.put("protocol", "http");
        domDirsProcessor.appendProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.jtpl", templateVars, domainDir + "/htdocs/.htaccess", userName, pacName, "644", false)
                new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.vm", templateVars, dom, domainDir + "/htdocs/.htaccess", userName, pacName, "644", false)
            );
        templateVars.put("PROTOCOL", "https");
        templateVars.put("protocol", "https");
        domDirsProcessor.appendProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.jtpl", templateVars, domainDir + "/htdocs-ssl/.htaccess", userName, pacName, "644", false)
                new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.vm", templateVars, dom, domainDir + "/htdocs-ssl/.htaccess", userName, pacName, "644", false)
            );
        domDirsProcessor.appendProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.jtpl", templateVars, domainDir + "/subs/www/index.html", userName, pacName, "644", false)
                new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs/www/index.html", userName, pacName, "644", false)
            );
        domDirsProcessor.appendProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.jtpl", templateVars, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
                new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
            );
        if (dynamicWeb) {
            domDirsProcessor.appendProcessor(
                    new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.jtpl", templateVars, domainDir + "/cgi/test.cgi", userName, pacName, "755", false)
                    new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi/test.cgi", userName, pacName, "755", false)
                );
            domDirsProcessor.appendProcessor(
                    new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.jtpl", templateVars, domainDir + "/cgi-ssl/test.cgi", userName, pacName, "755", false)
                    new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi-ssl/test.cgi", userName, pacName, "755", false)
                );
            domDirsProcessor.appendProcessor(
                    new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755")
@@ -305,57 +272,20 @@
        return domDirsProcessor;
    }
    private Processor createApacheVHostSetupProcessor(EntityManager em, Domain dom, Map<String, String> templateVars)
                throws ProcessorException {
    private Processor createApacheVHostSetupProcessor(EntityManager em, Domain dom)  throws ProcessorException {
        Map<String, Object> templateVars = new HashMap<String, Object>();
        String domName = dom.getName();
        int level = domName.split("\\.").length;
        String linkPrefix = Integer.toString(100 - level);
        String pac = dom.getUser().getPac().getName();
        Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
        query.setParameter("domname", dom.getName());
        // TODO: This code should be cleaned up after switching to the velocity template engine.
        query.setParameter("option", "indexes");
        if (query.getResultList().isEmpty()) {
            templateVars.put("INDEXES", "-Indexes");
        } else {
            templateVars.put("INDEXES", "+Indexes");
        }
        // TODO: This code should be cleaned up after switching to the velocity template engine.
        query.setParameter("option", "includes");
        if (query.getResultList().isEmpty()) {
            templateVars.put("INCLUDES", "-Includes");
        } else {
            templateVars.put("INCLUDES", "+IncludesNoExec");
        }
        // TODO: This code should be cleaned up after switching to the velocity template engine.
        query.setParameter("option", "multiviews");
        if (query.getResultList().isEmpty()) {
            templateVars.put("MULTIVIEWS", "-MultiViews");
        } else {
            templateVars.put("MULTIVIEWS", "+MultiViews");
        }
        // TODO: This code should be cleaned up after switching to the velocity template engine.
        query.setParameter("option", "htdocsfallback");
        if (query.getResultList().isEmpty()) {
            templateVars.put("NOHTDOCSFALLBACKHTTP",
            "    RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" +
            "    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" +
            "    RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:80)?$ [novary]\n" +
            "    RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d\n" +
            "    RewriteRule ^(.*) - [redirect=404,last]\n");
            templateVars.put("NOHTDOCSFALLBACKHTTPS",
            "    RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" +
            "    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" +
            "    RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:443)?$ [novary]\n" +
            "    RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} !-d\n" +
            "    RewriteRule ^(.*) - [redirect=404,last]\n");
        } else {
            templateVars.put("NOHTDOCSFALLBACKHTTP", "\n");
            templateVars.put("NOHTDOCSFALLBACKHTTPS", "\n");
        }
        ifOption(templateVars, query, "indexes", "+Indexes", "-Indexes");
        ifOption(templateVars, query, "includes", "+IncludesNoExec", "-Includes");
        ifOption(templateVars, query, "multiviews", "+MultiViews", "-MultiViews");
        ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE);
        Processor domSetupProcessor = new CompoundProcessor(
            new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
            new CreateFileProcessor("/de/hsadmin/mods/dom/httpd-vhost.vm", templateVars, dom, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
            new ShellProcessor("ls /etc/apache2/pems/" + pac + ".pem >/dev/null 2>&1" +
                    " && sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName + ".tmp" + 
                    " && (ls /etc/apache2/pems/" + pac + ".chain.pem >/dev/null 2>&1 || sed -i '/SSLCertificateChain.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ".tmp )" + 
@@ -370,6 +300,15 @@
        return domSetupProcessor;
    }
    private void ifOption(Map<String, Object> templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) {
        query.setParameter("option", option);
        if (query.getResultList().isEmpty()) {
            templateVars.put(option, optIsFalse);
        } else {
            templateVars.put(option, optIsTrue);
        }
    }
    private Processor createApacheVHostDeleteProcessor(Domain dom) {
        String domName = dom.getName();
        int level = domName.split("\\.").length;
@@ -381,32 +320,6 @@
                " && rm -rf " + dom.getUser().getHomedir() + "/doms/" + domName +
                " && invoke-rc.d apache2 reload >/dev/null 2>&1");
        return vhostDelProcessor;
    }
    private String selectVHostTemplate(Domain dom) {
        String domName = dom.getName();
        UnixUser user = dom.getUser();
        Pac pac = user.getPac();
        if (domName.equals(pac.getName() + ".hostsharing.net")) {
            return "/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl";
        }
        if (pac.isDynamicWeb() || dom.isPacDomain()) {
            return "/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl";
        }
        return "/de/hsadmin/mods/dom/httpd-vhost-static.jtpl";
    }
    private String getCurrentIPAddress(Pac pac) {
        return pac.getCurINetAddr().getInetAddr();
    }
    private String getOldIPAddress(Pac pac) {
        INetAddress oldINetAddr = pac.getOldINetAddr();
        if (oldINetAddr != null) {
            return oldINetAddr.getInetAddr();
        } else {
            return getCurrentIPAddress(pac);
        }
    }
}
hsarback/src/de/hsadmin/mods/dom/htaccess.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/dom/htaccess.vm
New file
@@ -0,0 +1 @@
Redirect permanent / ${protocol}://www.{domain.name}/
hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm
New file
@@ -0,0 +1,145 @@
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
<VirtualHost ${pac.curINetAddr.inetAddr}:80 ${pac.oldINetAddr.inetAddr}:80>
    ServerName ${dom.name}
    ServerAlias *.${dom.name}
    ServerAdmin webmaster@${dom.name}
    SuexecUserGroup ${dom.user.name} ${pac.name}
    DocumentRoot /home/doms/${dom.name}/htdocs
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
    Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
    Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
#end
    <Directory />
        Options -ExecCGI ${includes} ${indexes} ${multiviews} +SymLinksIfOwnerMatch
    </Directory>
    <Directory /home/doms/${dom.name}/>
        AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>
    <Location /fastcgi-bin/>
        SetHandler fcgid-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>
#else
    <Location /cgi-bin/>
        Redirect 501 /
    </Location>
    <Location /fastcgi-bin/>
        Redirect 501 /
    </Location>
#end
    RewriteEngine On
    RewriteOptions Inherit
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
    RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?\$ [novary]
    RewriteCond /home/doms/${dom.name}/subs/\$\{tolower:%1\} -d
    RewriteRule ^(.*) /home/doms/${dom.name}/subs/\$\{tolower:%1\}\$1 [last]
#if( !${htdocsfallback} )
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
    RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?\$ [novary]
    RewriteCond /home/doms/${dom.name}/subs/\$\{tolower:%1\} !-d
    RewriteRule ^(.*) - [redirect=404,last]
#end
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
    AddType application/x-httpd-php .php .php5 .php4 .php3
    Action application/x-httpd-php /fastcgi-bin/phpstub
#end
</VirtualHost>
<VirtualHost ${pac.curINetAddr.inetAddr}:443 ${pac.oldINetAddr.inetAddr}:443>
    ServerName ${dom.name}
    ServerAlias *.${dom.name}
    ServerAdmin ${dom.user.name}@${dom.name}
    SuexecUserGroup ${dom.user.name} ${pac.name}
    SSLEngine On
    SSLCertificateFile /etc/apache2/pems/default.pem
    SSLCertificateChainFile /etc/apache2/pems/default.chain.pem
    SSLCertificateFile /etc/apache2/pems/${pac.name}.pem
    SSLCertificateChainFile /etc/apache2/pems/${pac.name}.chain.pem
    DocumentRoot /home/doms/${dom.name}/htdocs-ssl
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
    Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
    Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
#end
    <Directory />
        SSLRequireSSL On
        Options -ExecCGI ${includes} ${indexes} ${multiviews} +SymLinksIfOwnerMatch
    </Directory>
    <Directory /home/doms/${dom.name}/>
        AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>
    <Location /fastcgi-bin/>
        SetHandler fcgid-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
    </Location>
#else
    <Location /cgi-bin/>
        Redirect 501 /
    </Location>
    <Location /fastcgi-bin/>
        Redirect 501 /
    </Location>
#end
    RewriteEngine On
    RewriteOptions Inherit
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
    RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?\$ [novary]
    RewriteCond /home/doms/${dom.name}/subs-ssl/\$\{tolower:%1\} -d
    RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/\$\{tolower:%1\}\$1 [last]
#if( !${htdocsfallback} )
    RewriteCond %{REQUEST_URI} !^/cgi-bin/
    RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
    RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:443)?\$ [novary]
    RewriteCond /home/doms/${dom.name}/subs-ssl/\$\{tolower:%1\} !-d
    RewriteRule ^(.*) - [redirect=404,last]
#end
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
    AddType application/x-httpd-php .php .php5 .php4 .php3
    Action application/x-httpd-php /fastcgi-bin/phpstub
#end
</VirtualHost>
hsarback/src/de/hsadmin/mods/dom/index.html.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/dom/index.html.vm
New file
@@ -0,0 +1,21 @@
<html>
<head>
<title>Willkommen bei ${dom.name}</title>
</head>
<body bgcolor="orange">
<h1>Willkommen bei ${dom.name}</h1>
<p>Diese neue Website wurde gerade bei der
<a href="http://www.hostsharing.net">Hostsharing eG</a>
f&uuml;r ${dom.user.comment} eingerichtet.</p>
<p>Der Inhaber der Domain ist bereits per Email unter
<a href="mailto:webmaster(at)${dom.name}">webmaster(at)${dom.name}</a>
zu erreichen.</p>
</body>
</html>
hsarback/src/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm
File was renamed from hsarback/src/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl
@@ -1,4 +1,4 @@
<!-- BEGIN: main -->#
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
@@ -8,6 +8,6 @@
####################################################
<!-- BEGIN: iterate -->{DOM}
<!-- END: iterate -->
<!-- END: main -->
#foreach( $whitelistdom in ${whitelist} )
${whitelistdom.name}
#end
hsarback/src/de/hsadmin/mods/dom/test.cgi.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/dom/test.cgi.vm
New file
@@ -0,0 +1,4 @@
#!/bin/sh
echo Content-type: text/plain
echo
echo Hello, world
hsarback/src/de/hsadmin/mods/dom/zonefile.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/dom/zonefile.vm
New file
@@ -0,0 +1,24 @@
$TTL 6H
${dom.name}. IN SOA dns.hostsharing.net. hostmaster.hostsharing.net. (
                ${sio}    ; serial secs since Jan 1 1970
                6H        ; refresh (>=10000)
                1H        ; retry (>=1800)
                1W        ; expire
                1H        ; minimum
)
${dom.name}.            IN        NS    dns1.hostsharing.net.
${dom.name}.            IN        NS    dns2.hostsharing.net.
${dom.name}.            IN        NS    dns3.hostsharing.net.
${dom.name}.            IN        MX    30 mailin1.hostsharing.net.
${dom.name}.            IN        MX    30 mailin2.hostsharing.net.
${dom.name}.            IN        MX    30 mailin3.hostsharing.net.
${dom.name}.            IN        A    ${pac.curINetAddr.inetAddr}
*.${dom.name}.        IN        MX    30 mailin1.hostsharing.net.
*.${dom.name}.        IN        MX    30 mailin2.hostsharing.net.
*.${dom.name}.        IN        MX    30 mailin3.hostsharing.net.
*.${dom.name}.        IN        A    ${pac.curINetAddr.inetAddr}
hsarback/src/de/hsadmin/mods/pac/BasePac.java
@@ -26,6 +26,7 @@
    private static final long serialVersionUID = 1491121619195513435L;
    public BasePac() {
        components = new HashSet<Component>();
    }
    public BasePac(String name, String desc, int sortPos) {
hsarback/src/de/hsadmin/mods/pac/Hive.java
@@ -21,6 +21,7 @@
import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Hives")
@@ -130,4 +131,9 @@
    public UnixUser owningUser(EntityManager em) {
        return null; // TODO: kinda somebody like root needed
    }
    public String getDefaultGateway() {
        String hiveIP = getInetAddr().getInetAddr();
        return Config.getInstance().getProperty("hsadmin.default_gateway", hiveIP.substring(0, hiveIP.lastIndexOf('.')) + ".1");
    }
}
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -1,26 +1,21 @@
package de.hsadmin.mods.pac;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.EntityManager;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.qserv.CompoundProcessor;
import de.hsadmin.core.qserv.CreateFileProcessor;
import de.hsadmin.core.qserv.EntityProcessorFactory;
//import de.hsadmin.core.qserv.MailerProcessor;
import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.ProcessorException;
import de.hsadmin.core.qserv.ShellProcessor;
import de.hsadmin.core.qserv.TemplateProcessor;
import de.hsadmin.core.qserv.CreateFileProcessor;
import de.hsadmin.core.qserv.VelocityProcessor;
import de.hsadmin.core.qserv.WaitingTasksProcessor;
import de.hsadmin.core.util.Config;
import de.hsadmin.core.util.PasswordTool;
import de.hsadmin.mods.user.UnixUser;
public class PacProcessorFactory implements EntityProcessorFactory {
@@ -32,19 +27,17 @@
        Hive hive = pac.getHive();
        UnixUser unixUser = getPacAdminUser(pac);
        String password = PasswordTool.generatePassword();
        Map<String, String> hiveValues = fillHiveValues(hive);
        List<Map<String, String>> pacValuesList = fillPacValuesList(hive, null);
        Processor priProcessor = new CompoundProcessor(
                createAddUserProc(pacName, unixUser, password), 
                createSetQuotaProc(pac),
                createEtcHostsProc(hiveValues, pacValuesList),
                createNetworkInterfacesProc(hiveValues, pacValuesList),
                createEtcHostsProc(hive),
                createNetworkInterfacesProc(hive),
                createIPTablesProc(),
                createSudouersProc(hiveValues, pacValuesList),
                createProftpdConfProc(hiveValues, pacValuesList),
                createSudouersProc(hive),
                createProftpdConfProc(hive),
                createMakePacDirectoryStructure(unixUser),
                createIfUp(pacName),
                createHttpdVirtualProc(pacName, pacValuesList),
                createHttpdVirtualProc(hive),
                createAccountingRulesProc());
        WaitingTasksProcessor secProcessor = new WaitingTasksProcessor(priProcessor);
        return secProcessor;
@@ -54,11 +47,9 @@
        return new ShellProcessor("mk-iptables-rules Accounting");
    }
    private Processor createHttpdVirtualProc(
            String pacName, List<Map<String, String>> pacValuesList) throws ProcessorException {
    private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException {
        Processor domSetupProcessor = new CompoundProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl",
                        new HashMap<String, String>(), pacValuesList.iterator(),
                new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive,
                        "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true),
                new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " +
                        "ls $PEM >/dev/null 2>&1 || ( " +
@@ -90,46 +81,36 @@
    public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
        Pac pac = (Pac) entity;
        Hive hive = pac.getHive();
        Map<String, String> hiveValues = fillHiveValues(hive);
        List<Map<String, String>> pacValuesList = fillPacValuesList(hive, pac);
        WaitingTasksProcessor waitingProcessor = new WaitingTasksProcessor(new CompoundProcessor(
                createIfDown(pac.getName()),
                createEtcHostsProc(hiveValues, pacValuesList),
                createNetworkInterfacesProc(hiveValues, pacValuesList),
                createSudouersProc(hiveValues, pacValuesList),
                createProftpdConfProc(hiveValues, pacValuesList),
                createHttpdVirtualProc(pac.getName(), pacValuesList),
                createEtcHostsProc(hive),
                createNetworkInterfacesProc(hive),
                createSudouersProc(hive),
                createProftpdConfProc(hive),
                createHttpdVirtualProc(hive),
                createAccountingRulesProc()));
        waitingProcessor.appendProcessor(pac.getHiveName(), createDelUserProc(pac.getName()), "remove packet");
        return waitingProcessor;
    }
    private Processor createEtcHostsProc(
            Map<String, String> hiveValues,
            List<Map<String, String>> pacValuesList) throws ProcessorException {
        return new TemplateProcessor("/de/hsadmin/mods/pac/hosts.jtpl", hiveValues, pacValuesList.iterator(), "/etc/hosts", true);
    private Processor createEtcHostsProc(Hive hive) throws ProcessorException {
        return new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", hive, "/etc/hosts", true);
    }
    private Processor createNetworkInterfacesProc(
            Map<String, String> hiveValues,
            List<Map<String, String>> pacValuesList) throws ProcessorException {
        return new TemplateProcessor("/de/hsadmin/mods/pac/interfaces.jtpl", hiveValues, pacValuesList.iterator(), "/etc/network/interfaces", true);
    private Processor createNetworkInterfacesProc(Hive hive) throws ProcessorException {
        return new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", hive, "/etc/network/interfaces", true);
    }
    private Processor createIPTablesProc() {
        return new ShellProcessor("mk-iptables-rules Accounting");
    }
    private Processor createSudouersProc(
            Map<String, String> hiveValues,
            List<Map<String, String>> pacValuesList) throws ProcessorException {
        return new TemplateProcessor("/de/hsadmin/mods/pac/sudoers.jtpl", hiveValues, pacValuesList.iterator(), "/etc/sudoers", true);
    private Processor createSudouersProc(Hive hive) throws ProcessorException {
        return new VelocityProcessor("/de/hsadmin/mods/pac/sudoers.vm", hive, "/etc/sudoers", true);
    }
    private Processor createProftpdConfProc(
            Map<String, String> hiveValues,
            List<Map<String, String>> pacValuesList) throws ProcessorException {
        return new TemplateProcessor("/de/hsadmin/mods/pac/proftpd-conf.jtpl", hiveValues, pacValuesList.iterator(), "/etc/proftpd/proftpd.conf", true);
    private Processor createProftpdConfProc(Hive hive) throws ProcessorException {
        return new VelocityProcessor("/de/hsadmin/mods/pac/proftpd-conf.vm", hive, "/etc/proftpd/proftpd.conf", true);
    }
    private Processor createAddUserProc(String pacName, UnixUser unixUser, String password) {
@@ -201,33 +182,6 @@
            throw new ProcessorException("packet contains users");
        }
        return unixUser;
    }
    private Map<String, String> fillHiveValues(Hive hive) {
        Map<String, String> hiveValues = new HashMap<String, String>();
        hiveValues.put("HIVE", hive.getName());
        String hiveIP = hive.getInetAddr().getInetAddr();
        hiveValues.put("HIVE_IP", hiveIP);
        String defaultGateway =
                Config.getInstance().getProperty("hsadmin.default_gateway", hiveIP.substring(0, hiveIP.lastIndexOf('.')) + ".1");
        defaultGateway =
            Config.getInstance().getProperty("hsadmin." + hive.getName() + ".default_gateway", defaultGateway);
        hiveValues.put("HIVE_GATEWAY", defaultGateway);
        return hiveValues;
    }
    private List<Map<String, String>> fillPacValuesList(Hive hive, Pac pacToSkip) {
        List<Map<String, String>> pacValuesList = new ArrayList<Map<String, String>>();
        Set<Pac> pacsSet = hive.getPacs();
        for (Pac p : pacsSet) {
            HashMap<String, String> pacValues = new HashMap<String, String>();
            pacValues.put("PAC", p.getName());
            pacValues.put("PAC_IP", p.getCurINetAddr().getInetAddr());
            if (pacToSkip == null || !pacToSkip.getName().equals(p.getName())) {
                pacValuesList.add(pacValues);
            }
        }
        return pacValuesList;
    }
}
hsarback/src/de/hsadmin/mods/pac/hosts.vm
File was renamed from hsarback/src/de/hsadmin/mods/pac/hosts.jtpl
@@ -1,4 +1,4 @@
<!-- BEGIN: main -->#
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
@@ -12,8 +12,8 @@
ff02::2         ip6-allrouters
ff02::3         ip6-allhosts
{HIVE_IP}    {HIVE}.hostsharing.net    {HIVE}    localhive
${hive.inetAddr.inetAddr}    ${hive.name}.hostsharing.net    ${hive.name}    localhive
<!-- BEGIN: iterate -->{PAC_IP}    {PAC}.hostsharing.net    {PAC}
<!-- END: iterate -->
<!-- END: main -->
#foreach( $pac in ${hive.pacs} )
${pac.curINetAddr.inetAddr}        ${pac.name}.hostsharing.net        ${pac.name}
#end
hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/pac/httpd-virtual.vm
New file
@@ -0,0 +1,11 @@
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
#foreach( $pac in ${hive.pacs} )
# ${pac.name}
NameVirtualHost ${pac.curINetAddr.inetAddr}:80
NameVirtualHost ${pac.curINetAddr.inetAddr}:443
#end
hsarback/src/de/hsadmin/mods/pac/interfaces.jtpl
File was deleted
hsarback/src/de/hsadmin/mods/pac/interfaces.vm
New file
@@ -0,0 +1,22 @@
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
        address ${hive.inetAddr.inetAddr}
        netmask 255.255.255.0
        gateway ${hive.defaultGateway}
#foreach( $pac in ${hive.pacs} )
iface eth0:${pac.name} inet static
        address ${pac.curINetAddr.inetAddr}
        netmask 255.255.255.0
#end
hsarback/src/de/hsadmin/mods/pac/proftpd-conf.vm
File was renamed from hsarback/src/de/hsadmin/mods/pac/proftpd-conf.jtpl
@@ -1,4 +1,4 @@
<!-- BEGIN: main -->#
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
@@ -58,11 +58,10 @@
  AllowOverwrite                on
</Directory>
<!-- BEGIN: iterate -->
####################################################
#foreach( $pac in ${hive.pacs} )
<VirtualHost {PAC_IP}>
        DefaultRoot             ~ {PAC}
<VirtualHost ${pac.curINetAddr.inetAddr}>
        DefaultRoot             ~ ${pac.name}
        ServerName              "Hostsharing eG"
        AllowOverwrite          on
        AllowForeignAddress     on
@@ -70,14 +69,14 @@
        <Limit LOGIN>
                Order           allow,deny
                AllowGroup      {PAC}
                AllowGroup      ${pac.name}
                DenyAll
        </Limit>
        <Anonymous /home/pacs/{PAC}/ftp>
                User    {PAC}
                Group   {PAC}
                UserAlias       anonymous {PAC}
                UserAlias       ftp {PAC}
        <Anonymous /home/pacs/${pac.name}/ftp>
                User            ${pac.name}
                Group           ${pac.name}
                UserAlias       anonymous ${pac.name}
                UserAlias       ftp ${pac.name}
                DirFakeUser     on ftp
                DirFakeGroup    on ftp
                DirFakeMode     000
@@ -87,6 +86,5 @@
                </Limit>
        </Anonymous>
</VirtualHost>
<!-- END: iterate -->
<!-- END: main -->
#end
        
hsarback/src/de/hsadmin/mods/pac/sudoers.vm
File was renamed from hsarback/src/de/hsadmin/mods/pac/sudoers.jtpl
@@ -1,4 +1,4 @@
<!-- BEGIN: main -->#
#
# This file is managed by HSAdmin.
# Do not edit manually. Changes will be overwritten.
#
@@ -22,6 +22,6 @@
####################################################
<!-- BEGIN: iterate -->{PAC} ALL = (%{PAC}) NOPASSWD: ALL
<!-- END: iterate -->
<!-- END: main -->
#foreach( $pac in ${hive.pacs} )
${pac.name} ALL = (%${pac.name}) NOPASSWD: ALL
#end
hsarback/src/net/sf/jtpl/Jtpl.java
File was deleted
hsarback/src/net/sf/jtpl/Template.java
File was deleted