Enable all services.

see #119
This commit is contained in:
Antoine Nguyen
2017-04-24 18:01:45 +02:00
parent 533cb13e97
commit ece218bbbe
3 changed files with 10 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import pwd
import stat import stat
from . import package from . import package
from . import system
from . import utils from . import utils
@@ -28,7 +29,7 @@ class Database(object):
def install_package(self): def install_package(self):
"""Install database package if required.""" """Install database package if required."""
package.backend.install_many(self.packages[package.backend.FORMAT]) package.backend.install_many(self.packages[package.backend.FORMAT])
utils.exec_cmd("service {} start".format(self.service)) system.enable_and_start_service(self.service)
class PostgreSQL(Database): class PostgreSQL(Database):
@@ -53,7 +54,7 @@ class PostgreSQL(Database):
pattern = "s/^host(.+)ident$/host$1md5/" pattern = "s/^host(.+)ident$/host$1md5/"
cfgfile = "/var/lib/pgsql/data/pg_hba.conf" cfgfile = "/var/lib/pgsql/data/pg_hba.conf"
utils.exec_cmd("perl -pi -e '{}' {}".format(pattern, cfgfile)) utils.exec_cmd("perl -pi -e '{}' {}".format(pattern, cfgfile))
utils.exec_cmd("service {} start".format(self.service)) system.enable_and_start_service(self.service)
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 postgresql query."""

View File

@@ -5,6 +5,7 @@ import pwd
from .. import database from .. import database
from .. import package from .. import package
from .. import system
from .. import utils from .. import utils
from . import base from . import base
@@ -102,5 +103,6 @@ class Dovecot(base.Installer):
code, output = utils.exec_cmd("service dovecot status") code, output = utils.exec_cmd("service dovecot status")
action = "start" if code else "restart" action = "start" if code else "restart"
utils.exec_cmd( utils.exec_cmd(
"service dovecot {} > /dev/null 2>&1".format(action), "service {} {} > /dev/null 2>&1".format(self.appname, action),
capture_output=False) capture_output=False)
system.enable_service(self.get_daemon_name())

View File

@@ -97,11 +97,7 @@ class Uwsgi(base.Installer):
def restart_daemon(self): def restart_daemon(self):
"""Restart daemon process.""" """Restart daemon process."""
instances = ["modoboa_instance"] code, output = utils.exec_cmd("service uwsgi status")
if self.config.getboolean("automx", "enabled"): action = "start" if code else "restart"
instances.append("automx_instance") utils.exec_cmd("service uwsgi {}".format(action))
for instance in instances: system.enable_service(self.get_daemon_name())
code, output = utils.exec_cmd("service uwsgi status {}".format(
instance))
action = "start" if code else "restart"
utils.exec_cmd("service uwsgi {}".format(action))