Merge branch 'master' of github.com:modoboa/modoboa-installer
This commit is contained in:
@@ -123,9 +123,9 @@ class MySQL(Database):
|
|||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
"deb": ["mysql-server", "libmysqlclient-dev"],
|
"deb": ["mysql-server", "libmysqlclient-dev"],
|
||||||
"rpm": ["mariadb", "mariadb-devel"],
|
"rpm": ["mariadb", "mariadb-devel","mariadb-server"],
|
||||||
}
|
}
|
||||||
service = "mysql"
|
service = "mariadb" if package.backend.FORMAT == "rpm" else "mysql"
|
||||||
|
|
||||||
def install_package(self):
|
def install_package(self):
|
||||||
"""Preseed package installation."""
|
"""Preseed package installation."""
|
||||||
@@ -134,9 +134,11 @@ class MySQL(Database):
|
|||||||
package.backend.preconfigure(
|
package.backend.preconfigure(
|
||||||
"mysql-server", "root_password_again", "password", self.dbpassword)
|
"mysql-server", "root_password_again", "password", self.dbpassword)
|
||||||
super(MySQL, self).install_package()
|
super(MySQL, self).install_package()
|
||||||
|
if package.backend.FORMAT == "rpm":
|
||||||
|
utils.exec_cmd("mysqladmin -u root password '{}'".format(self.dbpassword))
|
||||||
|
|
||||||
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):
|
def _exec_query(self, query, dbname=None, dbuser=None, dbpassword=None):
|
||||||
"""Exec a postgresql query."""
|
"""Exec a mysql query."""
|
||||||
if dbuser is None and dbpassword is None:
|
if dbuser is None and dbpassword is None:
|
||||||
dbuser = self.dbuser
|
dbuser = self.dbuser
|
||||||
dbpassword = self.dbpassword
|
dbpassword = self.dbpassword
|
||||||
@@ -150,6 +152,9 @@ class MySQL(Database):
|
|||||||
self._exec_query(
|
self._exec_query(
|
||||||
"CREATE USER '{}'@'%' IDENTIFIED BY '{}'".format(
|
"CREATE USER '{}'@'%' IDENTIFIED BY '{}'".format(
|
||||||
name, password))
|
name, password))
|
||||||
|
self._exec_query(
|
||||||
|
"CREATE USER '{}'@'localhost' IDENTIFIED BY '{}'".format(
|
||||||
|
name, password))
|
||||||
|
|
||||||
def create_database(self, name, owner):
|
def create_database(self, name, owner):
|
||||||
"""Create a database."""
|
"""Create a database."""
|
||||||
@@ -162,6 +167,9 @@ class MySQL(Database):
|
|||||||
self._exec_query(
|
self._exec_query(
|
||||||
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'%'"
|
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'%'"
|
||||||
.format(dbname, user))
|
.format(dbname, user))
|
||||||
|
self._exec_query(
|
||||||
|
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'localhost'"
|
||||||
|
.format(dbname, user))
|
||||||
|
|
||||||
def load_sql_file(self, dbname, dbuser, dbpassword, path):
|
def load_sql_file(self, dbname, dbuser, dbpassword, path):
|
||||||
"""Load SQL file."""
|
"""Load SQL file."""
|
||||||
|
|||||||
@@ -11,16 +11,19 @@ class CertificateBackend(object):
|
|||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
"""Set path to certificates."""
|
"""Set path to certificates."""
|
||||||
self.config = config
|
self.config = config
|
||||||
for base_dir in ["/etc/pki/tls", "/etc/ssl"]:
|
if not config.has_option("general", "tls_key_file"):
|
||||||
if os.path.exists(base_dir):
|
for base_dir in ["/etc/pki/tls", "/etc/ssl"]:
|
||||||
self.config.set(
|
if os.path.exists(base_dir):
|
||||||
"general", "tls_key_file",
|
self.config.set(
|
||||||
"{}/private/%(hostname)s.key".format(base_dir))
|
"general", "tls_key_file",
|
||||||
self.config.set(
|
"{}/private/%(hostname)s.key".format(base_dir))
|
||||||
"general", "tls_cert_file",
|
self.config.set(
|
||||||
"{}/certs/%(hostname)s.cert".format(base_dir))
|
"general", "tls_cert_file",
|
||||||
return
|
"{}/certs/%(hostname)s.cert".format(base_dir))
|
||||||
raise RuntimeError("Cannot find a directory to store certificate")
|
return
|
||||||
|
raise RuntimeError("Cannot find a directory to store certificate")
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class SelfSignedCertificate(CertificateBackend):
|
class SelfSignedCertificate(CertificateBackend):
|
||||||
|
|||||||
Reference in New Issue
Block a user