Add postfix module

parent 6b3a1dd5
......@@ -37,3 +37,6 @@ enabled = yes
[network]
enabled = yes
[postfix]
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 = "postfix"
POSTFIX_METHODS_NAMESPACE = "postfix"
POSTFIX_MAIN_CF = "/etc/postfix/main.cf"
##### Private classes #####
class Postfix(service.FunctionObject) :
### DBus methods ###
@service.functionMethod(POSTFIX_METHODS_NAMESPACE, in_signature="ss")
def regenerateMainCf(self, config_filename, templates_dir):
with open(config_filename, 'r') as postfix_config:
config = safe_load(postfix_config.read())
template_filename = path.join(templates_dir, config['template'] + '.tpl')
with open(template_filename, 'r') as template_text:
template = Template(template_text.read())
config_text = template.render(settings=config['settings'])
with open(POSTFIX_MAIN_CF, 'w+') as main_cf:
main_cf.write(config_text)
##### Public classes #####
class Service(service.Service) :
### Public ###
def initService(self) :
shared.Functions.addSharedObject(SERVICE_NAME, Postfix(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