Added autodiscover config.

fix #150
This commit is contained in:
Antoine Nguyen
2017-08-09 15:18:47 +02:00
parent 616c810de2
commit c32c0ea2ae
2 changed files with 17 additions and 3 deletions

View File

@@ -40,4 +40,5 @@ server {
uwsgi_param UWSGI_SCRIPT instance.wsgi:application;
uwsgi_pass modoboa;
}
%{extra_config}
}

View File

@@ -29,12 +29,12 @@ class Nginx(base.Installer):
})
return context
def _setup_config(self, app, hostname=None):
def _setup_config(self, app, hostname=None, extra_config=None):
"""Custom app configuration."""
if hostname is None:
hostname = self.config.get("general", "hostname")
context = self.get_template_context(app)
context.update({"hostname": hostname})
context.update({"hostname": hostname, "extra_config": extra_config})
src = self.get_file_path("{}.conf.tpl".format(app))
if package.backend.FORMAT == "deb":
dst = os.path.join(
@@ -57,11 +57,24 @@ class Nginx(base.Installer):
def post_run(self):
"""Additionnal tasks."""
self._setup_config("modoboa")
extra_modoboa_config = ""
if self.config.getboolean("automx", "enabled"):
hostname = "autoconfig.{}".format(
self.config.get("general", "domain"))
self._setup_config("automx", hostname)
extra_modoboa_config = """
location /autodiscover/autodiscover.xml {
include uwsgi_params;
uwsgi_pass automx;
}
location /mobileconfig {
include uwsgi_params;
uwsgi_pass automx;
}
"""
self._setup_config(
"modoboa", extra_config=extra_modoboa_config)
if not os.path.exists("{}/dhparam.pem".format(self.config_dir)):
cmd = "openssl dhparam -dsaparam -out dhparam.pem 4096"
utils.exec_cmd(cmd, cwd=self.config_dir)