replace acmebot with lego, replace some deprecated code

This commit is contained in:
Peter Hormanns 2020-06-08 13:17:27 +02:00
parent 64126e089e
commit 4b5fdd06ef
7 changed files with 40 additions and 39 deletions

View File

@ -8,23 +8,17 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/> <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-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-dbcp-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.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-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-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-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-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-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/geronimo-validation_1.0_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/mail.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/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/servlet-api-2.4.jar"/>
<classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/> <classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/>
<classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.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="lib" path="lib/xmlrpc-server-3.1.3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <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/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/commons-logging-api-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/hsadmin-util-4.0.1-SNAPSHOT.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"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -46,7 +46,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
} }
mainProcessor.appendProcessor(hiveName, createDomainDirectoriesProcessor(dom), "Setup Domain Directories"); mainProcessor.appendProcessor(hiveName, createDomainDirectoriesProcessor(dom), "Setup Domain Directories");
mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom), "Setup Apache VHost"); 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"); mainProcessor.appendProcessor(hiveName, createTriggerAcmebotProcessor(em, dom), "Trigger ACMEBot");
return mainProcessor; return mainProcessor;
} }
@ -56,10 +56,11 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
final UnixUser domUser = dom.getUser(); final UnixUser domUser = dom.getUser();
final Pac pac = domUser.getPac(); final Pac pac = domUser.getPac();
final Processor apacheVHostSetupProcessor = createApacheVHostSetupProcessor(em, dom); 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 Processor triggerAcmebotProcessor = createTriggerAcmebotProcessor(em, dom);
final WaitingTasksProcessor processor = new WaitingTasksProcessor( 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(); final Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.mail").split(",")) { for (String queueName : config.getProperty("queues.mail").split(",")) {
processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net"); processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
@ -71,7 +72,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
final Domain dom = (Domain) entity; final Domain dom = (Domain) entity;
final String domName = dom.getName(); final String domName = dom.getName();
final WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor( final WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
createACMEBotProcessor(em, dom) new NullProcessor()
// createACMEBotProcessor(em, dom)
); );
final Config config = Config.getInstance(); final Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.mail").split(",")) { for (String queueName : config.getProperty("queues.mail").split(",")) {
@ -347,27 +349,24 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
return new NullProcessor(); return new NullProcessor();
} else { } else {
return new ShellProcessor( return new ShellProcessor(
"rm -f /etc/apache2/pems-enabled/" + domName + ".crt" + "sudo -u acmebot /usr/local/sbin/hs-lego-wrapper " + domName);
" && rm -f /etc/apache2/pems-enabled/" + domName + ".key" + // " && ln -s /etc/apache2/pems-generated/" + domName + ".key /etc/apache2/pems-enabled/" + domName + ".key" +
" && rm -f /etc/apache2/pems-enabled/" + domName + ".chain" + // " && ln -s /etc/apache2/pems-generated/" + domName + ".crt /etc/apache2/pems-enabled/" + domName + ".crt" +
" && ln -s /etc/apache2/pems-generated/" + domName + ".key /etc/apache2/pems-enabled/" + domName + ".key" + // " && ln -s /etc/apache2/pems-generated/" + domName + ".chain /etc/apache2/pems-enabled/" + domName + ".chain" +
" && 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);
} }
} }
private Processor createACMEBotProcessor(final EntityManager em, final Domain dom) throws ProcessorException { // 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 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 String hiveName = dom.getHiveName();
final Map<String, Object> templateVars = new HashMap<String, Object>(); // final Map<String, Object> templateVars = new HashMap<String, Object>();
query.setParameter("hivename", hiveName); // query.setParameter("hivename", hiveName);
query.setParameter("option", "letsencrypt"); // query.setParameter("option", "letsencrypt");
templateVars.put("domains", query.getResultList()); // templateVars.put("domains", query.getResultList());
return new CompoundProcessor( // return new CompoundProcessor(
new CreateFileProcessor("/de/hsadmin/mods/dom/acmebot-domain.properties.vm", templateVars, dom, // new CreateFileProcessor("/de/hsadmin/mods/dom/acmebot-domain.properties.vm", templateVars, dom,
"/etc/hostsharing/acmebot/domain.properties.tmp", "acmebot", "acmebot", "640", true), // "/etc/hostsharing/acmebot/domain.properties.tmp", "acmebot", "acmebot", "640", true),
new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties")); // new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties"));
} // }
} }

View File

@ -104,10 +104,10 @@ public class UnixUser extends AbstractEntity implements Serializable {
shell = "/bin/false"; shell = "/bin/false";
} }
if (quotaSoftlimit == null) { if (quotaSoftlimit == null) {
quotaSoftlimit = new Integer(0); quotaSoftlimit = Integer.valueOf(0);
} }
if (quotaHardlimit == null) { if (quotaHardlimit == null) {
quotaHardlimit = new Integer(0); quotaHardlimit = Integer.valueOf(0);
} }
} }

View File

@ -79,7 +79,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
private void appendSetQuotaProcessor(CompoundProcessor aCP, UnixUser user) { private void appendSetQuotaProcessor(CompoundProcessor aCP, UnixUser user) {
Integer quotaSoft = user.getQuotaSoftlimit(); Integer quotaSoft = user.getQuotaSoftlimit();
if (quotaSoft == null) { if (quotaSoft == null) {
quotaSoft = new Integer(0); quotaSoft = Integer.valueOf(0);
} else { } else {
quotaSoft = quotaSoft * 1024; quotaSoft = quotaSoft * 1024;
} }
@ -90,7 +90,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
} }
Integer quotaHard = user.getQuotaHardlimit(); Integer quotaHard = user.getQuotaHardlimit();
if (quotaHard == null) { if (quotaHard == null) {
quotaHard = new Integer(0); quotaHard = Integer.valueOf(0);
} else { } else {
quotaHard = quotaHard * 1024; quotaHard = quotaHard * 1024;
} }

View File

@ -7,7 +7,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;

View File

@ -33,7 +33,7 @@ public class ModulePropertiesRemote implements IRemote {
properties.load(resourceAsStream); properties.load(resourceAsStream);
for (Object moduleKey : properties.keySet()) { for (Object moduleKey : properties.keySet()) {
Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey)); Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey));
Object newInstance = remoteClass.newInstance(); Object newInstance = remoteClass.getDeclaredConstructor().newInstance();
if (newInstance instanceof AbstractRemote) { if (newInstance instanceof AbstractRemote) {
Map<String,Object> modMap = new HashMap<String, Object>(); Map<String,Object> modMap = new HashMap<String, Object>();
modMap.put("module", moduleKey); modMap.put("module", moduleKey);
@ -58,7 +58,7 @@ public class ModulePropertiesRemote implements IRemote {
String fullPropertyName = fieldName+"."+s; String fullPropertyName = fieldName+"."+s;
propertiesList.add(createReferredPropertyInfo(fullPropertyName, f, s)); propertiesList.add(createReferredPropertyInfo(fullPropertyName, f, s));
} }
DefaultSelectableValues selectableValuesInstance = fieldIO.selectableValues().newInstance() ; DefaultSelectableValues selectableValuesInstance = fieldIO.selectableValues().getDeclaredConstructor().newInstance();
KindOfSelectableValue kind = selectableValuesInstance.getkind(); KindOfSelectableValue kind = selectableValuesInstance.getkind();
HashMap<String,Object> kindMap = new HashMap<String,Object>(); HashMap<String,Object> kindMap = new HashMap<String,Object>();
kindMap.put("kind", kind.name()); kindMap.put("kind", kind.name());

View File

@ -31,7 +31,7 @@ public class PropertyRemote implements IRemote {
properties.load(resourceAsStream); properties.load(resourceAsStream);
for (Object moduleKey : properties.keySet()) { for (Object moduleKey : properties.keySet()) {
Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey)); Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey));
Object newInstance = remoteClass.newInstance(); Object newInstance = remoteClass.getDeclaredConstructor().newInstance();
if (newInstance instanceof AbstractRemote) { if (newInstance instanceof AbstractRemote) {
AbstractRemote remote = (AbstractRemote) newInstance; AbstractRemote remote = (AbstractRemote) newInstance;
Class<? extends AbstractEntity> entityClass = remote.getAnnotatedEntityClass(); Class<? extends AbstractEntity> entityClass = remote.getAnnotatedEntityClass();