provide path variables to vhost template

This commit is contained in:
Peter Hormanns 2024-01-17 12:11:24 +01:00
parent 92be4acd7f
commit bf2a2a885e

View File

@ -267,6 +267,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
ifOption(templateVars, query, "passengerfriendlyerrorpages", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "cgi", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "fastcgi", Boolean.TRUE, Boolean.FALSE);
setPathInTemplate(templateVars, "passengerpython", "/usr/bin/python3", dom.getPassengerpython());
setPathInTemplate(templateVars, "passengernodejs", "/usr/bin/node", dom.getPassengernodejs());
setPathInTemplate(templateVars, "passengerruby", "/usr/bin/ruby", dom.getPassengerruby());
setPathInTemplate(templateVars, "fcgiphpbin", "/usr/bin/php", dom.getFcgiphpbin());
final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE);
final Processor domSetupProcessor = new CompoundProcessor(
isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"),
@ -296,6 +300,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
return domSetupProcessor;
}
private void setPathInTemplate(final Map<String, Object> templateVars, final String templateVariable, final String defaultPath, final String actualPath) {
String pathVariable = actualPath;
if (pathVariable == null || pathVariable.isEmpty()) {
pathVariable = defaultPath;
}
templateVars.put(templateVariable, pathVariable);
}
private void ifOption(Map<String, Object> templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) {
query.setParameter("option", option);
if (query.getResultList().isEmpty()) {