CentOS support.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
import os
|
||||
|
||||
from .. import package
|
||||
from .. import system
|
||||
from .. import utils
|
||||
|
||||
from . import base
|
||||
@@ -12,7 +14,17 @@ class Uwsgi(base.Installer):
|
||||
"""uWSGI installer."""
|
||||
|
||||
appname = "uwsgi"
|
||||
packages = ["uwsgi", "uwsgi-plugin-python"]
|
||||
packages = {
|
||||
"deb": ["uwsgi", "uwsgi-plugin-python"],
|
||||
"rpm": ["uwsgi", "uwsgi-plugin-python"],
|
||||
}
|
||||
|
||||
@property
|
||||
def socket_path(self):
|
||||
"""Return socket path."""
|
||||
if package.backend.FORMAT == "deb":
|
||||
return "/run/uwsgi/app/modoboa_instance/socket"
|
||||
return "/run/uwsgi/modoboa_instance.sock"
|
||||
|
||||
def get_template_context(self):
|
||||
"""Additionnal variables."""
|
||||
@@ -22,22 +34,35 @@ class Uwsgi(base.Installer):
|
||||
"modoboa_venv_path": self.config.get("modoboa", "venv_path"),
|
||||
"modoboa_instance_path": (
|
||||
self.config.get("modoboa", "instance_path")),
|
||||
"uwsgi_socket_path": self.config.get("uwsgi", "socket_path")
|
||||
"uwsgi_socket_path": self.socket_path
|
||||
})
|
||||
return context
|
||||
|
||||
def get_config_dir(self):
|
||||
"""Return appropriate configuration directory."""
|
||||
if package.backend.FORMAT == "deb":
|
||||
return os.path.join(self.config_dir, "apps-available")
|
||||
return "{}.d".format(self.config_dir)
|
||||
|
||||
def post_run(self):
|
||||
"""Additionnal tasks."""
|
||||
context = self.get_template_context()
|
||||
src = self.get_file_path("uwsgi.ini.tpl")
|
||||
dst = os.path.join(
|
||||
self.config_dir, "apps-available", "modoboa_instance.ini")
|
||||
dst = os.path.join(self.get_config_dir(), "modoboa_instance.ini")
|
||||
utils.copy_from_template(src, dst, context)
|
||||
link = os.path.join(
|
||||
self.config_dir, "apps-enabled", os.path.basename(dst))
|
||||
if os.path.exists(link):
|
||||
return
|
||||
os.symlink(dst, link)
|
||||
if package.backend.FORMAT == "deb":
|
||||
link = os.path.join(
|
||||
self.config_dir, "apps-enabled", os.path.basename(dst))
|
||||
if os.path.exists(link):
|
||||
return
|
||||
os.symlink(dst, link)
|
||||
else:
|
||||
system.add_user_to_group(
|
||||
"uwsgi", self.config.get("modoboa", "user"))
|
||||
pattern = (
|
||||
"s/emperor-tyrant = true/emperor-tyrant false/")
|
||||
utils.exec_cmd(
|
||||
"perl -pi -e '{}' /etc/uwsgi.ini".format(pattern))
|
||||
|
||||
def restart_daemon(self):
|
||||
"""Restart daemon process."""
|
||||
|
||||
Reference in New Issue
Block a user