|
|
|
@ -6,6 +6,7 @@ import shutil
|
|
|
|
|
import sys
|
|
|
|
|
import glob
|
|
|
|
|
import jinja2
|
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
def jinja_render_file(in_path, data, out_path):
|
|
|
|
|
render_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(in_path)))
|
|
|
|
@ -29,15 +30,27 @@ if not os.path.exists('/etc/postfix/sql'):
|
|
|
|
|
os.mkdir('/etc/postfix/sql')
|
|
|
|
|
|
|
|
|
|
for postfix_file in glob.glob("/conf/*.cf", recursive=True):
|
|
|
|
|
destination = os.path.join("/etc/postfix", os.path.basename(postfix_file))
|
|
|
|
|
p = path.Path(postfix_file)
|
|
|
|
|
p = p.relative_to(*p.parts[:2])
|
|
|
|
|
p = p.joinpath('/etc/postfix', *p.parts)
|
|
|
|
|
if not p.parent.isdir():
|
|
|
|
|
p.parent.mkdir(0o700)
|
|
|
|
|
|
|
|
|
|
destination = str(p)
|
|
|
|
|
shutil.copyfile(postfix_file, destination)
|
|
|
|
|
os.chmod(destination, 600)
|
|
|
|
|
|
|
|
|
|
for postfix_file in glob.glob("/conf/*.cf.jinja", recursive=True):
|
|
|
|
|
out_path = os.path.join("/etc/postfix", os.path.basename(postfix_file))
|
|
|
|
|
out_path = out_path[0:-6] # Remove .jinja from the output path
|
|
|
|
|
jinja_render_file(postfix_file, os.environ, out_path)
|
|
|
|
|
os.chmod(out_path, 600)
|
|
|
|
|
p = path.Path(postfix_file)
|
|
|
|
|
p = p.relative_to(*p.parts[:2])
|
|
|
|
|
p = p.joinpath('/etc/postfix', *p.parts)
|
|
|
|
|
if not p.parent.isdir():
|
|
|
|
|
p.parent.mkdir(0o700)
|
|
|
|
|
|
|
|
|
|
destination = str(p)
|
|
|
|
|
destination = destination[0:-6] # Remove .jinja from the output path
|
|
|
|
|
jinja_render_file(postfix_file, os.environ, destination)
|
|
|
|
|
os.chmod(destination, 600)
|
|
|
|
|
|
|
|
|
|
if os.path.exists("/overrides/postfix.cf"):
|
|
|
|
|
for line in open("/overrides/postfix.cf").read().strip().split("\n"):
|
|
|
|
|