2018-06-04 21:41:18 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
2019-01-08 00:38:06 +02:00
|
|
|
import logging as log
|
|
|
|
import sys
|
2022-01-31 19:19:15 +02:00
|
|
|
import subprocess
|
2019-07-25 10:33:57 +02:00
|
|
|
from socrate import system, conf
|
2018-06-04 21:41:18 +02:00
|
|
|
|
2019-01-08 05:16:05 +02:00
|
|
|
log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
|
2019-01-08 00:38:06 +02:00
|
|
|
|
2018-06-04 21:41:18 +02:00
|
|
|
# Actual startup script
|
2019-08-21 19:35:24 +02:00
|
|
|
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front"))
|
|
|
|
os.environ["IMAP_ADDRESS"] = system.resolve_address(os.environ.get("HOST_IMAP", "imap"))
|
2018-06-04 21:41:18 +02:00
|
|
|
|
2018-12-07 13:37:40 +02:00
|
|
|
os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576))
|
|
|
|
|
2018-06-04 21:41:18 +02:00
|
|
|
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)
|
|
|
|
|
2021-08-10 21:47:14 +02:00
|
|
|
conf.jinja("/defaults/default.ini", os.environ, "/data/_data_/_default_/domains/default.ini")
|
|
|
|
conf.jinja("/defaults/application.ini", os.environ, "/data/_data_/_default_/configs/application.ini")
|
|
|
|
conf.jinja("/defaults/php.ini", os.environ, "/etc/php7/php.ini")
|
2022-02-14 03:40:08 +02:00
|
|
|
# Start the fastcgi process manager now that config files have been adjusted
|
|
|
|
os.system("php-fpm7")
|
2018-06-04 21:41:18 +02:00
|
|
|
|
2021-08-10 21:47:14 +02:00
|
|
|
os.system("chown -R nginx:nginx /data")
|
2022-03-22 11:04:56 +02:00
|
|
|
os.system("chmod -R a+rX /var/www/webmail/")
|
2018-10-08 15:47:10 +02:00
|
|
|
|
2022-01-31 18:40:33 +02:00
|
|
|
subprocess.call(["/config.py"])
|
2021-08-10 21:47:14 +02:00
|
|
|
os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"])
|