Centos7 / Mariadb fixes

* Add mariadb-server package to the yum installation
* Add root password initial settings ("post"seed fashion)
* Handle centos "mysql" service name according to MariaDB switch
* add modoboa@localhost in order to give access
This commit is contained in:
Cédric de l'Epine
2016-09-13 16:38:24 +02:00
committed by GitHub
parent 3be02b9076
commit 2898c57127

View File

@@ -123,9 +123,9 @@ class MySQL(Database):
packages = {
"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):
"""Preseed package installation."""
@@ -134,9 +134,11 @@ class MySQL(Database):
package.backend.preconfigure(
"mysql-server", "root_password_again", "password", self.dbpassword)
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):
"""Exec a postgresql query."""
"""Exec a mysql query."""
if dbuser is None and dbpassword is None:
dbuser = self.dbuser
dbpassword = self.dbpassword
@@ -150,6 +152,9 @@ class MySQL(Database):
self._exec_query(
"CREATE USER '{}'@'%' IDENTIFIED BY '{}'".format(
name, password))
self._exec_query(
"CREATE USER '{}'@'localhost' IDENTIFIED BY '{}'".format(
name, password))
def create_database(self, name, owner):
"""Create a database."""
@@ -162,6 +167,9 @@ class MySQL(Database):
self._exec_query(
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'%'"
.format(dbname, user))
self._exec_query(
"GRANT ALL PRIVILEGES ON {}.* to '{}'@'localhost'"
.format(dbname, user))
def load_sql_file(self, dbname, dbuser, dbpassword, path):
"""Load SQL file."""