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:
@@ -6,7 +6,7 @@ An installer which deploy a complete mail server based on Modoboa.
|
||||
.. warning::
|
||||
|
||||
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::
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ timezone = Europe/Paris
|
||||
dbname = modoboa
|
||||
dbuser = modoboa
|
||||
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
|
||||
|
||||
[amavis]
|
||||
|
||||
@@ -109,14 +109,10 @@ class MySQL(Database):
|
||||
|
||||
def install_package(self):
|
||||
"""Preseed package installation."""
|
||||
cfg = (
|
||||
"mysql-server mysql-server/root_password password {}"
|
||||
.format(self.dbpassword))
|
||||
utils.exec_cmd("echo '{}' | debconf-set-selections".format(cfg))
|
||||
cfg = (
|
||||
"mysql-server mysql-server/root_password_again password {}"
|
||||
.format(self.dbpassword))
|
||||
utils.exec_cmd("echo '{}' | debconf-set-selections".format(cfg))
|
||||
utils.preconfigure_package(
|
||||
"mysql-server", "root_password", "password", self.dbpassword)
|
||||
utils.preconfigure_package(
|
||||
"mysql-server", "root_password_again", "password", self.dbpassword)
|
||||
super(MySQL, self).install_package()
|
||||
|
||||
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):
|
||||
|
||||
@@ -20,4 +20,10 @@ class Clamav(base.Installer):
|
||||
system.add_user_to_group(
|
||||
user, self.config.get("amavis", "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)
|
||||
|
||||
@@ -33,6 +33,13 @@ class Dovecot(base.Installer):
|
||||
"""Additional packages."""
|
||||
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):
|
||||
"""Additional variables."""
|
||||
context = super(Dovecot, self).get_template_context()
|
||||
|
||||
@@ -21,8 +21,8 @@ class Postfix(base.Installer):
|
||||
|
||||
def install_packages(self):
|
||||
"""Preconfigure postfix package installation."""
|
||||
cfg = "postfix postfix/main_mailer_type select No configuration"
|
||||
utils.exec_cmd("echo '{}' | debconf-set-selections".format(cfg))
|
||||
utils.preconfigure_package(
|
||||
"postfix", "main_mailer_type", "select", "No configuration")
|
||||
super(Postfix, self).install_packages()
|
||||
|
||||
def get_template_context(self):
|
||||
@@ -51,6 +51,9 @@ class Postfix(base.Installer):
|
||||
extensions = self.config.get("modoboa", "extensions")
|
||||
exts_with_maps = ["modoboa-admin", "modoboa-admin-relaydomains",
|
||||
"modoboa-postfix-autoreply"]
|
||||
if extensions == "all":
|
||||
extensions = exts_with_maps
|
||||
else:
|
||||
extensions = [ext for ext in exts_with_maps if ext in extensions]
|
||||
if not extensions:
|
||||
return
|
||||
|
||||
@@ -4,6 +4,7 @@ import contextlib
|
||||
import datetime
|
||||
import glob
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import string
|
||||
import subprocess
|
||||
@@ -66,6 +67,18 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, **kwargs):
|
||||
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):
|
||||
"""Install a package system-wide."""
|
||||
if update:
|
||||
|
||||
Reference in New Issue
Block a user