2018-07-26 21:41:11 +02:00
|
|
|
#!/usr/bin/python3
|
2017-09-24 14:42:40 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
import glob
|
2018-07-26 21:41:11 +02:00
|
|
|
import multiprocessing
|
2019-01-07 23:49:10 +02:00
|
|
|
import logging as log
|
|
|
|
import sys
|
2019-01-24 14:28:21 +02:00
|
|
|
from mailustart import resolve, convert
|
2018-07-26 21:41:11 +02:00
|
|
|
|
|
|
|
from podop import run_server
|
|
|
|
|
2019-01-08 05:16:05 +02:00
|
|
|
log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
|
2018-07-26 21:41:11 +02:00
|
|
|
|
|
|
|
def start_podop():
|
|
|
|
os.setuid(8)
|
2019-01-17 16:32:47 +02:00
|
|
|
url = "http://" + os.environ["ADMIN_ADDRESS"] + "/internal/dovecot/§"
|
2019-01-07 23:49:10 +02:00
|
|
|
run_server(0, "dovecot", "/tmp/podop.socket", [
|
2019-01-17 16:32:47 +02:00
|
|
|
("quota", "url", url ),
|
|
|
|
("auth", "url", url),
|
|
|
|
("sieve", "url", url),
|
2018-07-26 21:41:11 +02:00
|
|
|
])
|
2017-11-10 16:54:41 +02:00
|
|
|
|
2017-09-24 14:42:40 +02:00
|
|
|
# Actual startup script
|
2018-10-22 16:02:43 +02:00
|
|
|
os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front"))
|
|
|
|
os.environ["REDIS_ADDRESS"] = resolve(os.environ.get("REDIS_ADDRESS", "redis"))
|
2019-01-17 16:32:47 +02:00
|
|
|
os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("ADMIN_ADDRESS", "admin"))
|
2018-10-22 16:02:43 +02:00
|
|
|
if os.environ["WEBMAIL"] != "none":
|
|
|
|
os.environ["WEBMAIL_ADDRESS"] = resolve(os.environ.get("WEBMAIL_ADDRESS", "webmail"))
|
2017-09-24 14:42:40 +02:00
|
|
|
|
2018-09-27 16:13:02 +02:00
|
|
|
for dovecot_file in glob.glob("/conf/*.conf"):
|
2017-09-24 15:44:44 +02:00
|
|
|
convert(dovecot_file, os.path.join("/etc/dovecot", os.path.basename(dovecot_file)))
|
2017-09-24 14:42:40 +02:00
|
|
|
|
2018-07-26 21:41:11 +02:00
|
|
|
# Run Podop, then postfix
|
|
|
|
multiprocessing.Process(target=start_podop).start()
|
2019-01-08 05:00:15 +02:00
|
|
|
os.system("chown mail:mail /mail")
|
|
|
|
os.system("chown -R mail:mail /var/lib/dovecot /conf")
|
2017-09-24 15:44:44 +02:00
|
|
|
os.execv("/usr/sbin/dovecot", ["dovecot", "-c", "/etc/dovecot/dovecot.conf", "-F"])
|