parent
342551c925
commit
9ddff713da
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import shlex
|
||||
import sys
|
||||
import glob
|
||||
import jinja2
|
||||
|
||||
def jinja_render_file(in_path, data, out_path):
|
||||
render_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(in_path)))
|
||||
output = render_environment.get_template(os.path.basename(in_path)).render(**data)
|
||||
|
||||
with open(out_path, 'w', encoding='utf-8') as rf:
|
||||
rf.write(output)
|
||||
|
||||
for dovecot_file in glob.glob("/conf/**/*.conf", recursive=True):
|
||||
destination = os.path.join("/etc/dovecot", dovecot_file[6:])
|
||||
shutil.copyfile(dovecot_file, destination)
|
||||
|
||||
for dovecot_file in glob.glob("/conf/**/*.jinja", recursive=True):
|
||||
out_path = os.path.join("/etc/dovecot", dovecot_file[6:-6])
|
||||
jinja_render_file(dovecot_file, os.environ, out_path)
|
||||
os.chmod(out_path, 600)
|
||||
|
||||
for dovecot_file in glob.glob("/overrides/**/*.conf", recursive=True):
|
||||
destination = os.path.join("/etc/dovecot", dovecot_file[6:])
|
||||
shutil.copyfile(dovecot_file, destination)
|
||||
|
||||
for dovecot_file in glob.glob("/overrides/**/*.jinja", recursive=True):
|
||||
out_path = os.path.join("/etc/dovecot", dovecot_file[6:-6])
|
||||
jinja_render_file(dovecot_file, os.environ, out_path)
|
||||
os.chmod(out_path, 600)
|
||||
|
||||
os.system("/bin/mkdir -p /data/vmail")
|
||||
os.system("/bin/chmod u=rwX,g=rX,o=rX /data")
|
||||
os.system("/bin/chown mail: /data/vmail")
|
||||
os.system("/bin/chmod u=rwX,g=rX,o= /data/vmail")
|
||||
|
||||
os.system("/bin/mkdir -p /data/sieve/global/")
|
||||
os.system("/bin/chown mail:mail /data/sieve")
|
||||
|
||||
# Run CMD
|
||||
os.system(shlex.quote(' '.join(sys.argv[1:])))
|
Loading…
Reference in New Issue