|
|
|
@ -8,6 +8,8 @@ import glob
|
|
|
|
|
import jinja2
|
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
original_umask = os.umask(0)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
@ -31,23 +33,23 @@ for postfix_file in glob.glob("/conf/**/**.cf", recursive=True):
|
|
|
|
|
p = p.relative_to(*p.parts[:2])
|
|
|
|
|
p = p.joinpath('/etc/postfix', *p.parts)
|
|
|
|
|
if not p.parent.is_dir():
|
|
|
|
|
p.parent.mkdir(700)
|
|
|
|
|
p.parent.mkdir(0o700)
|
|
|
|
|
|
|
|
|
|
destination = str(p)
|
|
|
|
|
shutil.copyfile(postfix_file, destination)
|
|
|
|
|
os.chmod(destination, 600)
|
|
|
|
|
os.chmod(destination, 0o600)
|
|
|
|
|
|
|
|
|
|
for postfix_file in glob.glob("/conf/**/**.cf.jinja", recursive=True):
|
|
|
|
|
p = pathlib.Path(postfix_file)
|
|
|
|
|
p = p.relative_to(*p.parts[:2])
|
|
|
|
|
p = p.joinpath('/etc/postfix', *p.parts)
|
|
|
|
|
if not p.parent.is_dir():
|
|
|
|
|
p.parent.mkdir(700)
|
|
|
|
|
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)
|
|
|
|
|
os.chmod(destination, 0x600)
|
|
|
|
|
|
|
|
|
|
if os.path.exists("/overrides/postfix.cf"):
|
|
|
|
|
for line in open("/overrides/postfix.cf").read().strip().split("\n"):
|
|
|
|
@ -63,4 +65,7 @@ os.system("/usr/lib/postfix/sbin/post-install meta_directory=/etc/postfix create
|
|
|
|
|
# Before starting postfix, we need to check permissions on /queue
|
|
|
|
|
# in the event that postfix,postdrop id have changed
|
|
|
|
|
os.system("postfix set-permissions")
|
|
|
|
|
|
|
|
|
|
os.umask(original_umask)
|
|
|
|
|
|
|
|
|
|
os.system("postfix start-fg")
|
|
|
|
|