Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
11d094f3
Commit
11d094f3
authored
Mar 20, 2019
by
Дмитрий Никулин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add MailD plugin
parent
5004e43c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
main.conf
configs/settingsd/main.conf
+3
-0
fmod_maild.py
plugins/functions/fmod_maild.py
+57
-0
No files found.
configs/settingsd/main.conf
View file @
11d094f3
...
...
@@ -43,3 +43,6 @@ enabled = yes
[
ssl
]
enabled
=
yes
[
maild
]
enabled
=
yes
plugins/functions/fmod_maild.py
0 → 100644
View file @
11d094f3
# -*- 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment