Provide domain.properties for ACMEBot.
This commit is contained in:
parent
7a8cc5246c
commit
d3d0d75a82
@ -54,7 +54,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
UnixUser domUser = dom.getUser();
|
||||
Pac pac = domUser.getPac();
|
||||
final Processor apacheVHostSetupProcessor = createApacheVHostSetupProcessor(em, dom);
|
||||
final Processor letencryptSetupProcessor = createLetencryptSetupProcessor(em, dom);
|
||||
final Processor letencryptSetupProcessor = createACMEBotProcessor(em, dom);
|
||||
WaitingTasksProcessor processor = new WaitingTasksProcessor(new CompoundProcessor(apacheVHostSetupProcessor, letencryptSetupProcessor));
|
||||
Config config = Config.getInstance();
|
||||
for (String queueName : config.getProperty("queues.mail").split(",")) {
|
||||
@ -77,7 +77,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
mainProcessor.appendProcessor(queueName, createMailinUnsetupProcessor(em, dom), queueName + ".hostsharing.net");
|
||||
}
|
||||
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
|
||||
mainProcessor.appendProcessor(dom.getHiveName(), createLetencryptUnsetProcessor(dom), "remove letsencrypt config");
|
||||
mainProcessor.appendProcessor(dom.getHiveName(), createACMEBotProcessor(em, dom), "remove letsencrypt config");
|
||||
return mainProcessor;
|
||||
}
|
||||
|
||||
@ -326,39 +326,17 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
return vhostDelProcessor;
|
||||
}
|
||||
|
||||
private Processor createLetencryptSetupProcessor(final EntityManager em, final Domain dom) {
|
||||
final Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
|
||||
final String domName = dom.getName();
|
||||
query.setParameter("domname", domName);
|
||||
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");
|
||||
if (query.getResultList().isEmpty()) {
|
||||
// remove LE config
|
||||
return createLetencryptUnsetProcessor(dom);
|
||||
} else {
|
||||
// setup LE
|
||||
return new ShellProcessor(
|
||||
"mkdir -p /var/lib/letsencrypt/webroot/" + domName +
|
||||
" && chown root:root /var/lib/letsencrypt/webroot/" + domName +
|
||||
" && chmod 0755 /var/lib/letsencrypt/webroot/" + domName +
|
||||
" && mkdir -p /var/lib/letsencrypt/webroot/" + domName + "/.well-known" +
|
||||
" && chown root:root /var/lib/letsencrypt/webroot/" + domName + "/.well-known" +
|
||||
" && chmod 0755 /var/lib/letsencrypt/webroot/" + domName + "/.well-known" +
|
||||
" && mkdir -p /var/lib/letsencrypt/webroot/" + domName + "/.well-known/acme-challenge" +
|
||||
" && chown root:root /var/lib/letsencrypt/webroot/" + domName + "/.well-known/acme-challenge" +
|
||||
" && chmod 0755 /var/lib/letsencrypt/webroot/" + domName + "/.well-known/acme-challenge" +
|
||||
" && mkdir -p /etc/letsencrypt/renewal/" +
|
||||
" && mkdir -p /etc/letsencrypt/live/" + domName +
|
||||
" && mkdir -p /etc/letsencrypt/archive/" + domName +
|
||||
" && echo \"subs=" + dom.getValidsubdomainnames() + "\" > /etc/letsencrypt/renewal/" + domName + ".conf" );
|
||||
}
|
||||
}
|
||||
|
||||
private Processor createLetencryptUnsetProcessor(final Domain dom) {
|
||||
final String domName = dom.getName();
|
||||
return new ShellProcessor("rm -rf /var/lib/letsencrypt/webroot/" + domName +
|
||||
" && rm -rf /etc/letsencrypt/archive/" + domName +
|
||||
" && rm -rf /etc/letsencrypt/live/" + domName +
|
||||
" && rm -f /etc/letsencrypt/renewal/" + domName + ".conf");
|
||||
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", false),
|
||||
new ShellProcessor("mv /etc/hostsharing/acmebot/domain.properties.tmp /etc/hostsharing/acmebot/domain.properties"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
#
|
||||
# This file is managed by HSAdmin.
|
||||
# Do not edit manually. Changes will be overwritten.
|
||||
#
|
||||
|
||||
#foreach( $domain in $domains )
|
||||
${domain.name} = ${domain.getValidsubdomainnames}
|
||||
#end
|
Loading…
Reference in New Issue
Block a user