HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2020-06-08 4b5fdd06efe3c4c5c8510a8ccd54965db716c462
replace acmebot with lego, replace some deprecated code
7 files modified
79 ■■■■ changed files
hsarback/.classpath 17 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 47 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/user/UnixUser.java 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java 1 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/remote/PropertyRemote.java 2 ●●● patch | view | raw | blame | history
hsarback/.classpath
@@ -8,23 +8,17 @@
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/>
    <classpathentry kind="lib" path="lib/commons-beanutils-1.8.3.jar"/>
    <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
    <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
    <classpathentry kind="lib" path="lib/commons-dbcp-1.4.jar"/>
    <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
    <classpathentry kind="lib" path="lib/commons-lang-2.4.jar"/>
    <classpathentry kind="lib" path="lib/commons-net2-2.0.jar"/>
    <classpathentry kind="lib" path="lib/commons-pool-1.5.4.jar"/>
    <classpathentry kind="lib" path="lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar"/>
    <classpathentry kind="lib" path="lib/geronimo-jms_1.1_spec-1.1.1.jar"/>
    <classpathentry kind="lib" path="lib/geronimo-jpa_2.0_spec-1.1.jar"/>
    <classpathentry kind="lib" path="lib/geronimo-jta_1.1_spec-1.1.1.jar"/>
    <classpathentry kind="lib" path="lib/geronimo-validation_1.0_spec-1.1.jar"/>
    <classpathentry kind="lib" path="lib/mail.jar"/>
    <classpathentry kind="lib" path="lib/openjpa-2.1.1.jar"/>
    <classpathentry kind="lib" path="lib/org.apache.bval.bundle-0.2-incubating.jar"/>
    <classpathentry kind="lib" path="lib/serp-1.13.1.jar"/>
    <classpathentry kind="lib" path="lib/servlet-api-2.4.jar"/>
    <classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/>
    <classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.jar"/>
@@ -32,8 +26,17 @@
    <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="lib" path="lib/commons-logging-1.1.1.jar"/>
    <classpathentry kind="lib" path="lib/commons-logging-api-1.1.1.jar"/>
    <classpathentry kind="lib" path="lib/hsadmin-util-4.0.1-SNAPSHOT.jar"/>
    <classpathentry kind="lib" path="lib/commons-beanutils-1.9.2.jar"/>
    <classpathentry kind="lib" path="lib/commons-collections-3.2.2.jar"/>
    <classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
    <classpathentry kind="lib" path="lib/commons-lang3-3.9.jar"/>
    <classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
    <classpathentry kind="lib" path="lib/commons-pool-1.6.jar"/>
    <classpathentry kind="lib" path="lib/openjpa-2.4.3.jar"/>
    <classpathentry kind="lib" path="lib/org.apache.bval.bundle-0.5.jar"/>
    <classpathentry kind="lib" path="lib/serp-1.15.1.jar"/>
    <classpathentry kind="lib" path="lib/xbean-asm6-shaded-4.8.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -46,7 +46,7 @@
        }
        mainProcessor.appendProcessor(hiveName, createDomainDirectoriesProcessor(dom), "Setup Domain Directories");
        mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom), "Setup Apache VHost");
        mainProcessor.appendProcessor(hiveName, createACMEBotProcessor(em, dom), "Setup ACMEBot");
//        mainProcessor.appendProcessor(hiveName, createACMEBotProcessor(em, dom), "Setup ACMEBot");
        mainProcessor.appendProcessor(hiveName, createTriggerAcmebotProcessor(em, dom), "Trigger ACMEBot");
        return mainProcessor;
    }
@@ -56,10 +56,11 @@
        final UnixUser domUser = dom.getUser();
        final Pac pac = domUser.getPac();
        final Processor apacheVHostSetupProcessor = createApacheVHostSetupProcessor(em, dom);
        final Processor letencryptSetupProcessor = createACMEBotProcessor(em, dom);
//        final Processor letencryptSetupProcessor = createACMEBotProcessor(em, dom);
        final Processor triggerAcmebotProcessor = createTriggerAcmebotProcessor(em, dom);
        final WaitingTasksProcessor processor = new WaitingTasksProcessor(
                new CompoundProcessor(new ShellProcessor("salt-call state.sls pacs"), apacheVHostSetupProcessor, letencryptSetupProcessor, triggerAcmebotProcessor));
                new CompoundProcessor(new ShellProcessor("salt-call state.sls pacs"), apacheVHostSetupProcessor, triggerAcmebotProcessor));
//                new CompoundProcessor(new ShellProcessor("salt-call state.sls pacs"), apacheVHostSetupProcessor, letencryptSetupProcessor, triggerAcmebotProcessor));
        final Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.mail").split(",")) {
            processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
@@ -70,8 +71,9 @@
    public <T extends AbstractEntity> Processor createDeleteProcessor(final EntityManager em, final T entity) throws ProcessorException {
        final Domain dom = (Domain) entity;
        final String domName = dom.getName();
        final WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
                createACMEBotProcessor(em, dom)
        final WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
                new NullProcessor()
//                createACMEBotProcessor(em, dom)
            );
        final Config config = Config.getInstance();
        for (String queueName : config.getProperty("queues.mail").split(",")) {
@@ -347,27 +349,24 @@
            return new NullProcessor();
        } else {
            return new ShellProcessor(
                    "rm -f /etc/apache2/pems-enabled/" + domName + ".crt" +
                    " && rm -f /etc/apache2/pems-enabled/" + domName + ".key" +
                    " && rm -f /etc/apache2/pems-enabled/" + domName + ".chain" +
                    " && ln -s /etc/apache2/pems-generated/" + domName + ".key /etc/apache2/pems-enabled/" + domName + ".key" +
                    " && ln -s /etc/apache2/pems-generated/" + domName + ".crt /etc/apache2/pems-enabled/" + domName + ".crt" +
                    " && ln -s /etc/apache2/pems-generated/" + domName + ".chain /etc/apache2/pems-enabled/" + domName + ".chain" +
                    " && sudo -u acmebot /usr/sbin/acmebot -d " + domName);
                    "sudo -u acmebot /usr/local/sbin/hs-lego-wrapper " + domName);
//                    " && ln -s /etc/apache2/pems-generated/" + domName + ".key /etc/apache2/pems-enabled/" + domName + ".key" +
//                    " && ln -s /etc/apache2/pems-generated/" + domName + ".crt /etc/apache2/pems-enabled/" + domName + ".crt" +
//                    " && ln -s /etc/apache2/pems-generated/" + domName + ".chain /etc/apache2/pems-enabled/" + domName + ".chain" +
        }
    }
    private Processor createACMEBotProcessor(final EntityManager em, final Domain dom) throws ProcessorException {
        final Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.user.pac.hive.name = :hivename");
        final String hiveName = dom.getHiveName();
        final Map<String, Object> templateVars = new HashMap<String, Object>();
        query.setParameter("hivename", hiveName);
        query.setParameter("option", "letsencrypt");
        templateVars.put("domains", query.getResultList());
        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),
                new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties"));
    }
//    private Processor createACMEBotProcessor(final EntityManager em, final Domain dom) throws ProcessorException {
//        final Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.user.pac.hive.name = :hivename");
//        final String hiveName = dom.getHiveName();
//        final Map<String, Object> templateVars = new HashMap<String, Object>();
//        query.setParameter("hivename", hiveName);
//        query.setParameter("option", "letsencrypt");
//        templateVars.put("domains", query.getResultList());
//        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),
//                new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties"));
//    }
}
hsarback/src/de/hsadmin/mods/user/UnixUser.java
@@ -104,10 +104,10 @@
            shell = "/bin/false";
        }
        if (quotaSoftlimit == null) {
            quotaSoftlimit = new Integer(0);
            quotaSoftlimit = Integer.valueOf(0);
        }
        if (quotaHardlimit == null) {
            quotaHardlimit = new Integer(0);
            quotaHardlimit = Integer.valueOf(0);
        }
    }
hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java
@@ -79,7 +79,7 @@
    private void appendSetQuotaProcessor(CompoundProcessor aCP, UnixUser user) {
        Integer quotaSoft = user.getQuotaSoftlimit();
        if (quotaSoft == null) {
            quotaSoft = new Integer(0);
            quotaSoft = Integer.valueOf(0);
        } else {
            quotaSoft = quotaSoft * 1024;
        }
@@ -90,7 +90,7 @@
        }
        Integer quotaHard = user.getQuotaHardlimit();
        if (quotaHard == null) {
            quotaHard = new Integer(0);
            quotaHard = Integer.valueOf(0);
        } else {
            quotaHard = quotaHard * 1024;
        }
hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java
@@ -7,7 +7,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import javax.persistence.EntityManager;
import javax.persistence.Query;
hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java
@@ -33,7 +33,7 @@
                properties.load(resourceAsStream);                
                for (Object moduleKey : properties.keySet()) {
                    Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey));
                    Object newInstance = remoteClass.newInstance();
                    Object newInstance = remoteClass.getDeclaredConstructor().newInstance();
                    if (newInstance instanceof AbstractRemote) {
                        Map<String,Object> modMap = new HashMap<String, Object>();
                        modMap.put("module", moduleKey);
@@ -58,7 +58,7 @@
                                    String fullPropertyName = fieldName+"."+s;
                                    propertiesList.add(createReferredPropertyInfo(fullPropertyName, f, s));
                                }
                                DefaultSelectableValues selectableValuesInstance = fieldIO.selectableValues().newInstance() ;
                                DefaultSelectableValues selectableValuesInstance = fieldIO.selectableValues().getDeclaredConstructor().newInstance();
                                KindOfSelectableValue kind = selectableValuesInstance.getkind(); 
                                HashMap<String,Object> kindMap = new HashMap<String,Object>();
                                kindMap.put("kind", kind.name());
hsarback/src/de/hsadmin/remote/PropertyRemote.java
@@ -31,7 +31,7 @@
                properties.load(resourceAsStream);                
                for (Object moduleKey : properties.keySet()) {
                    Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey));
                    Object newInstance = remoteClass.newInstance();
                    Object newInstance = remoteClass.getDeclaredConstructor().newInstance();
                    if (newInstance instanceof AbstractRemote) {
                        AbstractRemote remote = (AbstractRemote) newInstance;
                        Class<? extends AbstractEntity> entityClass = remote.getAnnotatedEntityClass();