CentOS support.
This commit is contained in:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user