2022-10-08 15:55:40 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-09-24 14:42:40 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
import glob
|
2018-07-26 21:41:11 +02:00
|
|
|
import multiprocessing
|
|
|
|
|
2021-10-29 15:34:00 +02:00
|
|
|
from podop import run_server
|
2019-07-25 10:33:57 +02:00
|
|
|
from socrate import system, conf
|
2018-07-26 21:41:11 +02:00
|
|
|
|
2023-10-27 16:10:13 +02:00
|
|
|
system.set_env(log_filters=[r'Error\: SSL context initialization failed, disabling SSL\: Can\'t load SSL certificate \(ssl_cert setting\)\: The certificate is empty$'])
|
2018-07-26 21:41:11 +02:00
|
|
|
|
|
|
|
def start_podop():
|
2022-12-23 11:58:06 +02:00
|
|
|
system.drop_privs_to('mail')
|
2023-08-28 11:17:25 +02:00
|
|
|
url = "http://" + os.environ["ADMIN_ADDRESS"] + ":8080/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-09-27 16:13:02 +02:00
|
|
|
for dovecot_file in glob.glob("/conf/*.conf"):
|
2019-07-25 10:33:57 +02:00
|
|
|
conf.jinja(dovecot_file, os.environ, os.path.join("/etc/dovecot", os.path.basename(dovecot_file)))
|
2017-09-24 14:42:40 +02:00
|
|
|
|
2019-10-03 10:31:00 +02:00
|
|
|
os.makedirs("/conf/bin", exist_ok=True)
|
2019-09-27 20:57:15 +02:00
|
|
|
for script_file in glob.glob("/conf/*.script"):
|
|
|
|
out_file = os.path.join("/conf/bin/", os.path.basename(script_file).replace('.script',''))
|
|
|
|
conf.jinja(script_file, os.environ, out_file)
|
2019-10-03 10:32:36 +02:00
|
|
|
os.chmod(out_file, 0o555)
|
2019-09-27 20:57:15 +02:00
|
|
|
|
2018-07-26 21:41:11 +02:00
|
|
|
# Run Podop, then postfix
|
2019-01-08 05:00:15 +02:00
|
|
|
os.system("chown mail:mail /mail")
|
|
|
|
os.system("chown -R mail:mail /var/lib/dovecot /conf")
|
2022-11-27 11:59:18 +02:00
|
|
|
|
|
|
|
multiprocessing.Process(target=start_podop).start()
|
2023-10-27 16:10:13 +02:00
|
|
|
cmd = ['/usr/sbin/dovecot', '-c', '/etc/dovecot/dovecot.conf', '-F']
|
|
|
|
system.run_process_and_forward_output(cmd)
|