Add MailD plugin

parent 5004e43c
......@@ -43,3 +43,6 @@ enabled = yes
[ssl]
enabled = yes
[maild]
enabled = yes
# -*- coding: utf-8 -*-
import socket
import os
from yaml import dump, safe_load
from settingsd import const
from settingsd import config
from settingsd import service
from settingsd import shared
from settingsd import logger
import settingsd.tools as tools
from settingsd.tools.process import execProcess
import settingsd.tools.editors
from os import path
from jinja2 import Template
##### Private constants #####
SERVICE_NAME = "maild"
MAILD_METHODS_NAMESPACE = "maild"
MAILD_DRWEB_INI = "/etc/opt/drweb.com/drweb.ini"
MAILD_MILTER_HOOK = "/etc/opt/drweb.com/milterhook.lua"
##### Private classes #####
class MailD(service.FunctionObject) :
### DBus methods ###
@service.functionMethod(MAILD_METHODS_NAMESPACE, in_signature="sss")
def regenerateDrwebIni(self, config_filename, drweb_ini_templates_dir, lua_templates_dir):
with open(config_filename, 'r') as maild_config:
config = safe_load(maild_config.read())
self.renderTemplate(config['template'], drweb_ini_templates_dir, config['settings'], MAILD_DRWEB_INI)
self.renderTemplate(config['template'], lua_templates_dir, config['settings'], MAILD_MILTER_HOOK)
def renderTemplate(self, template, templates_dir, settings, output_filename):
template_filename = path.join(templates_dir, template + '.tpl')
with open(template_filename, 'r') as template_text:
template = Template(template_text.read())
content = template.render(settings=settings)
with open(output_filename, 'w+') as outfile:
outfile.write(content)
##### Public classes #####
class Service(service.Service) :
### Public ###
def initService(self) :
shared.Functions.addSharedObject(SERVICE_NAME, MailD(SERVICE_NAME, self))
### Private ###
@classmethod
def serviceName(self) :
return SERVICE_NAME
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment