CentOS support.

This commit is contained in:
Antoine Nguyen
2016-05-31 12:41:50 +02:00
parent 5c32d7d535
commit 451c3b4695
24 changed files with 1184 additions and 112 deletions

View File

@@ -2,10 +2,12 @@
import os
from .. import package
from .. import system
from .. import utils
from . import base
from .uwsgi import Uwsgi
class Nginx(base.Installer):
@@ -13,7 +15,10 @@ class Nginx(base.Installer):
"""Nginx installer."""
appname = "nginx"
packages = ["nginx", "ssl-cert"]
packages = {
"deb": ["nginx", "ssl-cert"],
"rpm": ["nginx"]
}
def get_template_context(self):
"""Additionnal variables."""
@@ -21,7 +26,7 @@ class Nginx(base.Installer):
context.update({
"modoboa_instance_path": (
self.config.get("modoboa", "instance_path")),
"uwsgi_socket_path": self.config.get("uwsgi", "socket_path")
"uwsgi_socket_path": Uwsgi(self.config).socket_path
})
return context
@@ -30,13 +35,20 @@ class Nginx(base.Installer):
hostname = self.config.get("general", "hostname")
context = self.get_template_context()
src = self.get_file_path("nginx.conf.tpl")
dst = os.path.join(
self.config_dir, "sites-available", "{}.conf".format(hostname))
utils.copy_from_template(src, dst, context)
link = os.path.join(
self.config_dir, "sites-enabled", os.path.basename(dst))
if os.path.exists(link):
return
os.symlink(dst, link)
if package.backend.FORMAT == "deb":
dst = os.path.join(
self.config_dir, "sites-available", "{}.conf".format(hostname))
utils.copy_from_template(src, dst, context)
link = os.path.join(
self.config_dir, "sites-enabled", os.path.basename(dst))
if os.path.exists(link):
return
os.symlink(dst, link)
group = "www-data"
else:
dst = os.path.join(
self.config_dir, "conf.d", "{}.conf".format(hostname))
utils.copy_from_template(src, dst, context)
group = "nginx"
system.add_user_to_group(
"www-data", self.config.get("modoboa", "user"))
group, self.config.get("modoboa", "user"))