#!/usr/bin/python3 import os import shutil import logging as log import sys from mailustart import resolve, convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["IMAP_ADDRESS"] = resolve(os.environ.get("IMAP_ADDRESS", "imap")) os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576)) base = "/data/_data_/_default_/" shutil.rmtree(base + "domains/", ignore_errors=True) os.makedirs(base + "domains", exist_ok=True) os.makedirs(base + "configs", exist_ok=True) convert("/default.ini", "/data/_data_/_default_/domains/default.ini") convert("/application.ini", "/data/_data_/_default_/configs/application.ini") convert("/php.ini", "/usr/local/etc/php/conf.d/rainloop.ini") os.system("chown -R www-data:www-data /data") os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
from mailustart import resolve, convert from podop import run_server log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) def start_podop(): os.setuid(8) url = "http://" + os.environ["ADMIN_ADDRESS"] + "/internal/dovecot/§" run_server(0, "dovecot", "/tmp/podop.socket", [ ("quota", "url", url ), ("auth", "url", url), ("sieve", "url", url), ]) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["REDIS_ADDRESS"] = resolve(os.environ.get("REDIS_ADDRESS", "redis")) os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("ADMIN_ADDRESS", "admin")) if os.environ["WEBMAIL"] != "none": os.environ["WEBMAIL_ADDRESS"] = resolve(os.environ.get("WEBMAIL_ADDRESS", "webmail")) for dovecot_file in glob.glob("/conf/*.conf"): convert(dovecot_file, os.path.join("/etc/dovecot", os.path.basename(dovecot_file))) # Run Podop, then postfix multiprocessing.Process(target=start_podop).start() os.system("chown mail:mail /mail") os.system("chown -R mail:mail /var/lib/dovecot /conf") os.execv("/usr/sbin/dovecot", ["dovecot", "-c", "/etc/dovecot/dovecot.conf", "-F"])
#!/usr/bin/python3 import os import logging as log import sys from mailustart import convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) os.environ["MAX_FILESIZE"] = str( int(int(os.environ.get("MESSAGE_SIZE_LIMIT")) * 0.66 / 1048576)) convert("/php.ini", "/usr/local/etc/php/conf.d/roundcube.ini") # Fix some permissions os.system("mkdir -p /data/gpg") os.system("chown -R www-data:www-data /data") # Run apache os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
#!/usr/bin/python3 import os import logging as log import sys from mailustart import convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) convert("/unbound.conf", "/etc/unbound/unbound.conf") os.execv("/usr/sbin/unbound", ["-c /etc/unbound/unbound.conf"])
("alias", "url", url + "alias/§"), ("domain", "url", url + "domain/§"), ("mailbox", "url", url + "mailbox/§"), ("senderaccess", "url", url + "sender/access/§"), ("senderlogin", "url", url + "sender/login/§")]) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("ADMIN_ADDRESS", "admin")) os.environ["HOST_ANTISPAM"] = resolve( os.environ.get("HOST_ANTISPAM", "antispam:11332")) os.environ["HOST_LMTP"] = resolve(os.environ.get("HOST_LMTP", "imap:2525")) for postfix_file in glob.glob("/conf/*.cf"): convert(postfix_file, os.path.join("/etc/postfix", os.path.basename(postfix_file))) if os.path.exists("/overrides/postfix.cf"): for line in open("/overrides/postfix.cf").read().strip().split("\n"): line = line.strip() if line and line[0] != "#": os.system('postconf -e "{}"'.format(line)) if os.path.exists("/overrides/postfix.master"): for line in open("/overrides/postfix.master").read().strip().split("\n"): os.system('postconf -Me "{}"'.format(line)) for map_file in glob.glob("/overrides/*.map"): destination = os.path.join("/etc/postfix", os.path.basename(map_file)) shutil.copyfile(map_file, destination) os.system("postmap {}".format(destination))
args["HOST_WEBMAIL"] = args.get("HOST_WEBMAIL", "webmail") if args["WEBMAIL"] != "none": args["HOST_WEBMAIL"] = resolve(args.get("HOST_WEBMAIL")) args["HOST_WEBDAV"] = args.get("HOST_WEBDAV", "webdav:5232") if args["WEBDAV"] != "none": args["HOST_WEBDAV"] = resolve(args.get("HOST_WEBDAV")) # TLS configuration cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem") keypair_name = os.getenv("TLS_KEYPAIR_FILENAME", default="key.pem") args["TLS"] = { "cert": ("/certs/%s" % cert_name, "/certs/%s" % keypair_name), "letsencrypt": ("/certs/letsencrypt/live/mailu/fullchain.pem", "/certs/letsencrypt/live/mailu/privkey.pem"), "mail": ("/certs/%s" % cert_name, "/certs/%s" % keypair_name), "mail-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" # Build final configuration paths convert("/conf/tls.conf", "/etc/nginx/tls.conf", args) convert("/conf/proxy.conf", "/etc/nginx/proxy.conf", args) convert("/conf/nginx.conf", "/etc/nginx/nginx.conf", args) if os.path.exists("/var/run/nginx.pid"): os.system("nginx -s reload")
#!/usr/bin/python3 import os import glob import logging as log import sys from mailustart import resolve, convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) if "HOST_REDIS" not in os.environ: os.environ["HOST_REDIS"] = "redis" for rspamd_file in glob.glob("/conf/*"): convert(rspamd_file, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file))) # Run rspamd os.execv("/usr/sbin/rspamd", ["rspamd", "-i", "-f"])
args["HOST_WEBMAIL"] = resolve(args.get("HOST_WEBMAIL")) args["HOST_WEBDAV"] = args.get("HOST_WEBDAV", "webdav:5232") if args["WEBDAV"] != "none": args["HOST_WEBDAV"] = resolve(args.get("HOST_WEBDAV")) # TLS configuration cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem") keypair_name = os.getenv("TLS_KEYPAIR_FILENAME", default="key.pem") args["TLS"] = { "cert": ("/certs/%s" % cert_name, "/certs/%s" % keypair_name), "letsencrypt": ("/certs/letsencrypt/live/mailu/fullchain.pem", "/certs/letsencrypt/live/mailu/privkey.pem"), "mail": ("/certs/%s" % cert_name, "/certs/%s" % keypair_name), "mail-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" # Build final configuration paths convert("/conf/tls.conf", "/etc/nginx/tls.conf", args) convert("/conf/proxy.conf", "/etc/nginx/proxy.conf", args) convert("/conf/nginx.conf", "/etc/nginx/nginx.conf", args) if os.path.exists("/var/run/nginx.pid"): os.system("nginx -s reload")
("transport", "url", url + "transport/§"), ("alias", "url", url + "alias/§"), ("domain", "url", url + "domain/§"), ("mailbox", "url", url + "mailbox/§"), ("senderaccess", "url", url + "sender/access/§"), ("senderlogin", "url", url + "sender/login/§") ]) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("ADMIN_ADDRESS", "admin")) os.environ["HOST_ANTISPAM"] = resolve(os.environ.get("HOST_ANTISPAM", "antispam:11332")) os.environ["HOST_LMTP"] = resolve(os.environ.get("HOST_LMTP", "imap:2525")) for postfix_file in glob.glob("/conf/*.cf"): convert(postfix_file, os.path.join("/etc/postfix", os.path.basename(postfix_file))) if os.path.exists("/overrides/postfix.cf"): for line in open("/overrides/postfix.cf").read().strip().split("\n"): os.system('postconf -e "{}"'.format(line)) if os.path.exists("/overrides/postfix.master"): for line in open("/overrides/postfix.master").read().strip().split("\n"): os.system('postconf -Me "{}"'.format(line)) for map_file in glob.glob("/overrides/*.map"): destination = os.path.join("/etc/postfix", os.path.basename(map_file)) shutil.copyfile(map_file, destination) os.system("postmap {}".format(destination)) os.remove(destination)
#!/usr/bin/python3 import os import logging as log import sys from mailustart import convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576)) convert("/php.ini", "/usr/local/etc/php/conf.d/roundcube.ini") # Fix some permissions os.system("mkdir -p /data/gpg") os.system("chown -R www-data:www-data /data") # Run apache os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
#!/usr/bin/python3 import os import shutil import logging as log import sys from mailustart import resolve, convert log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["IMAP_ADDRESS"] = resolve(os.environ.get("IMAP_ADDRESS", "imap")) os.environ["MAX_FILESIZE"] = str( int(int(os.environ.get("MESSAGE_SIZE_LIMIT")) * 0.66 / 1048576)) base = "/data/_data_/_default_/" shutil.rmtree(base + "domains/", ignore_errors=True) os.makedirs(base + "domains", exist_ok=True) os.makedirs(base + "configs", exist_ok=True) convert("/default.ini", "/data/_data_/_default_/domains/default.ini") convert("/application.ini", "/data/_data_/_default_/configs/application.ini") convert("/php.ini", "/usr/local/etc/php/conf.d/rainloop.ini") os.system("chown -R www-data:www-data /data") os.execv("/usr/local/bin/apache2-foreground", ["apache2-foreground"])
def start_podop(): os.setuid(8) url = "http://" + os.environ["ADMIN_ADDRESS"] + "/internal/dovecot/§" run_server(0, "dovecot", "/tmp/podop.socket", [ ("quota", "url", url), ("auth", "url", url), ("sieve", "url", url), ]) # Actual startup script os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("FRONT_ADDRESS", "front")) os.environ["REDIS_ADDRESS"] = resolve(os.environ.get("REDIS_ADDRESS", "redis")) os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("ADMIN_ADDRESS", "admin")) if os.environ["WEBMAIL"] != "none": os.environ["WEBMAIL_ADDRESS"] = resolve( os.environ.get("WEBMAIL_ADDRESS", "webmail")) for dovecot_file in glob.glob("/conf/*.conf"): convert(dovecot_file, os.path.join("/etc/dovecot", os.path.basename(dovecot_file))) # Run Podop, then postfix multiprocessing.Process(target=start_podop).start() os.system("chown mail:mail /mail") os.system("chown -R mail:mail /var/lib/dovecot /conf") os.execv("/usr/sbin/dovecot", ["dovecot", "-c", "/etc/dovecot/dovecot.conf", "-F"])