2017-09-24 17:50:10 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import jinja2
|
|
|
|
import os
|
2017-11-07 17:16:41 +02:00
|
|
|
|
2017-09-24 17:50:10 +02:00
|
|
|
convert = lambda src, dst, args: open(dst, "w").write(jinja2.Template(open(src).read()).render(**args))
|
|
|
|
|
|
|
|
args = os.environ.copy()
|
|
|
|
|
|
|
|
args["TLS"] = {
|
|
|
|
"cert": ("/certs/cert.pem", "/certs/key.pem"),
|
2017-11-07 17:16:41 +02:00
|
|
|
"mail": ("/certs/cert.pem", "/certs/key.pem"),
|
2017-09-24 17:50:10 +02:00
|
|
|
"letsencrypt": ("/certs/letsencrypt/live/mailu/fullchain.pem",
|
|
|
|
"/certs/letsencrypt/live/mailu/privkey.pem"),
|
|
|
|
"notls": None
|
|
|
|
}[args["TLS_FLAVOR"]]
|
|
|
|
|
|
|
|
if args["TLS"] and not all(os.path.exists(file_path) for file_path in args["TLS"]):
|
|
|
|
print("Missing cert or key file, disabling TLS")
|
|
|
|
args["TLS_ERROR"] = "yes"
|
|
|
|
|
|
|
|
|
2017-09-24 18:43:14 +02:00
|
|
|
convert("/conf/tls.conf", "/etc/nginx/tls.conf", args)
|
2017-09-24 17:50:10 +02:00
|
|
|
convert("/conf/nginx.conf", "/etc/nginx/nginx.conf", args)
|
|
|
|
os.system("nginx -s reload")
|