Few fixes.

Ubuntu installation (fix #4)
Generate map files when all shortcut is used (see #8)
Fix freshclam execution on Ubuntu
This commit is contained in:
Antoine Nguyen
2015-11-06 09:45:05 +01:00
parent 1824707d76
commit 5496f0caef
7 changed files with 41 additions and 16 deletions

View File

@@ -6,7 +6,7 @@ An installer which deploy a complete mail server based on Modoboa.
.. warning:: .. warning::
This tool is still in beta stage, it has been tested on Debian This tool is still in beta stage, it has been tested on Debian
Jessie (8) only. Jessie (8) and Ubuntu Trusty (14.04) only.
.. warning:: .. warning::

View File

@@ -26,7 +26,7 @@ timezone = Europe/Paris
dbname = modoboa dbname = modoboa
dbuser = modoboa dbuser = modoboa
dbpassword = password dbpassword = password
# Extensions to install (you can use the 'all' shortcut) # Extensions to install (to install all of them, use: all)
extensions = modoboa-admin modoboa-admin-relaydomains modoboa-admin-limits modoboa-amavis modoboa-pdfcredentials modoboa-postfix-autoreply modoboa-sievefilters modoboa-stats modoboa-webmail extensions = modoboa-admin modoboa-admin-relaydomains modoboa-admin-limits modoboa-amavis modoboa-pdfcredentials modoboa-postfix-autoreply modoboa-sievefilters modoboa-stats modoboa-webmail
[amavis] [amavis]

View File

@@ -109,14 +109,10 @@ class MySQL(Database):
def install_package(self): def install_package(self):
"""Preseed package installation.""" """Preseed package installation."""
cfg = ( utils.preconfigure_package(
"mysql-server mysql-server/root_password password {}" "mysql-server", "root_password", "password", self.dbpassword)
.format(self.dbpassword)) utils.preconfigure_package(
utils.exec_cmd("echo '{}' | debconf-set-selections".format(cfg)) "mysql-server", "root_password_again", "password", self.dbpassword)
cfg = (
"mysql-server mysql-server/root_password_again password {}"
.format(self.dbpassword))
utils.exec_cmd("echo '{}' | debconf-set-selections".format(cfg))
super(MySQL, self).install_package() super(MySQL, self).install_package()
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None): def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):

View File

@@ -20,4 +20,10 @@ class Clamav(base.Installer):
system.add_user_to_group( system.add_user_to_group(
user, self.config.get("amavis", "user") user, self.config.get("amavis", "user")
) )
utils.exec_cmd("freshclam", sudo_user=user) if utils.dist_name == "ubuntu":
# Stop freshclam daemon to allow manual download
utils.exec_cmd("service clamav-freshclam stop")
utils.exec_cmd("freshclam", sudo_user=user)
utils.exec_cmd("service clamav-freshclam start")
else:
utils.exec_cmd("freshclam", sudo_user=user)

View File

@@ -33,6 +33,13 @@ class Dovecot(base.Installer):
"""Additional packages.""" """Additional packages."""
return self.packages + ["dovecot-{}".format(self.db_driver)] return self.packages + ["dovecot-{}".format(self.db_driver)]
def install_packages(self):
"""Preconfigure Dovecot if needed."""
if utils.dist_name() == "ubuntu":
utils.preconfigure_package(
"dovecot-core", "create-ssl-cert", "boolean", "false")
super(Dovecot, self).install_packages()
def get_template_context(self): def get_template_context(self):
"""Additional variables.""" """Additional variables."""
context = super(Dovecot, self).get_template_context() context = super(Dovecot, self).get_template_context()

View File

@@ -21,8 +21,8 @@ class Postfix(base.Installer):
def install_packages(self): def install_packages(self):
"""Preconfigure postfix package installation.""" """Preconfigure postfix package installation."""
cfg = "postfix postfix/main_mailer_type select No configuration" utils.preconfigure_package(
utils.exec_cmd("echo '{}' | debconf-set-selections".format(cfg)) "postfix", "main_mailer_type", "select", "No configuration")
super(Postfix, self).install_packages() super(Postfix, self).install_packages()
def get_template_context(self): def get_template_context(self):
@@ -51,9 +51,12 @@ class Postfix(base.Installer):
extensions = self.config.get("modoboa", "extensions") extensions = self.config.get("modoboa", "extensions")
exts_with_maps = ["modoboa-admin", "modoboa-admin-relaydomains", exts_with_maps = ["modoboa-admin", "modoboa-admin-relaydomains",
"modoboa-postfix-autoreply"] "modoboa-postfix-autoreply"]
extensions = [ext for ext in exts_with_maps if ext in extensions] if extensions == "all":
if not extensions: extensions = exts_with_maps
return else:
extensions = [ext for ext in exts_with_maps if ext in extensions]
if not extensions:
return
cmd = ( cmd = (
"{} {} postfix_maps --dbtype {} --extensions {} --dburl {} {}" "{} {} postfix_maps --dbtype {} --extensions {} --dburl {} {}"
.format(python_path, script_path, self.dbengine, .format(python_path, script_path, self.dbengine,

View File

@@ -4,6 +4,7 @@ import contextlib
import datetime import datetime
import glob import glob
import os import os
import platform
import shutil import shutil
import string import string
import subprocess import subprocess
@@ -66,6 +67,18 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, **kwargs):
return process.returncode, output return process.returncode, output
def dist_name():
"""Try to guess the distribution name."""
name, version, _id = platform.linux_distribution()
return "unknown" if not name else name.lower()
def preconfigure_package(name, question, qtype, answer):
"""Pre-configure a package before installation."""
line = "{0} {0}/{1} {2} {3}".format(name, question, qtype, answer)
exec_cmd("echo '{}' | debconf-set-selections".format(line))
def install_system_package(name, update=False): def install_system_package(name, update=False):
"""Install a package system-wide.""" """Install a package system-wide."""
if update: if update: