HOST_* and *_ADDRESS variables cleanup

master
Ionut Filip 6 years ago
parent 7885fb8a41
commit 4c25c83419

@ -83,11 +83,11 @@ class ConfigManager(dict):
self.config = dict() self.config = dict()
def resolve_host(self): def resolve_host(self):
self.config['HOST_IMAP'] = resolve(self.config['HOST_IMAP']) self.config['IMAP_ADDRESS'] = resolve(self.config['HOST_IMAP'])
self.config['HOST_POP3'] = resolve(self.config['HOST_POP3']) self.config['POP3_ADDRESS'] = resolve(self.config['HOST_POP3'])
self.config['HOST_AUTHSMTP'] = resolve(self.config['HOST_AUTHSMTP']) self.config['AUTHSMTP_ADDRESS'] = resolve(self.config['HOST_AUTHSMTP'])
self.config['HOST_SMTP'] = resolve(self.config['HOST_SMTP']) self.config['SMTP_ADDRESS'] = resolve(self.config['HOST_SMTP'])
self.config['HOST_REDIS'] = resolve(self.config['HOST_REDIS']) self.config['REDIS_ADDRESS'] = resolve(self.config['HOST_REDIS'])
def __coerce_value(self, value): def __coerce_value(self, value):
if isinstance(value, str) and value.lower() in ('true','yes'): if isinstance(value, str) and value.lower() in ('true','yes'):
@ -111,8 +111,8 @@ class ConfigManager(dict):
template = self.DB_TEMPLATES[self.config['DB_FLAVOR']] template = self.DB_TEMPLATES[self.config['DB_FLAVOR']]
self.config['SQLALCHEMY_DATABASE_URI'] = template.format(**self.config) self.config['SQLALCHEMY_DATABASE_URI'] = template.format(**self.config)
self.config['RATELIMIT_STORAGE_URL'] = 'redis://{0}/2'.format(self.config['HOST_REDIS']) self.config['RATELIMIT_STORAGE_URL'] = 'redis://{0}/2'.format(self.config['REDIS_ADDRESS'])
self.config['QUOTA_STORAGE_URL'] = 'redis://{0}/1'.format(self.config['HOST_REDIS']) self.config['QUOTA_STORAGE_URL'] = 'redis://{0}/1'.format(self.config['REDIS_ADDRESS'])
# update the app config itself # update the app config itself
app.config = self app.config = self

@ -41,10 +41,10 @@ http {
# Favicon stuff # Favicon stuff
root /static; root /static;
# Variables for proxifying # Variables for proxifying
set $admin {{ HOST_ADMIN }}; set $admin {{ ADMIN_ADDRESS }};
set $antispam {{ HOST_ANTISPAM }}; set $antispam {{ ANTISPAM_ADDRESS }};
set $webmail {{ HOST_WEBMAIL }}; set $webmail {{ WEBMAIL_ADDRESS }};
set $webdav {{ HOST_WEBDAV }}; set $webdav {{ WEBDAV_ADDRESS }};
# Always listen over HTTP # Always listen over HTTP
listen 80; listen 80;
@ -168,7 +168,7 @@ http {
# Forwarding authentication server # Forwarding authentication server
server { server {
# Variables for proxifying # Variables for proxifying
set $admin {{ HOST_ADMIN }}; set $admin {{ ADMIN_ADDRESS }};
listen 127.0.0.1:8000; listen 127.0.0.1:8000;

@ -14,14 +14,14 @@ with open("/etc/resolv.conf") as handle:
content = handle.read().split() content = handle.read().split()
args["RESOLVER"] = content[content.index("nameserver") + 1] args["RESOLVER"] = content[content.index("nameserver") + 1]
args["HOST_ADMIN"] = resolve(args.get("HOST_ADMIN", "admin")) args["ADMIN_ADDRESS"] = resolve(args.get("HOST_ADMIN", "admin"))
args["HOST_ANTISPAM"] = resolve(args.get("HOST_ANTISPAM", "antispam:11334")) args["ANTISPAM_ADDRESS"] = resolve(args.get("HOST_ANTISPAM", "antispam:11334"))
args["HOST_WEBMAIL"] = args.get("HOST_WEBMAIL", "webmail") args["HOST_WEBMAIL"] = args.get("HOST_WEBMAIL", "webmail")
if args["WEBMAIL"] != "none": if args["WEBMAIL"] != "none":
args["HOST_WEBMAIL"] = resolve(args.get("HOST_WEBMAIL")) args["WEBMAIL_ADDRESS"] = resolve(args.get("HOST_WEBMAIL"))
args["HOST_WEBDAV"] = args.get("HOST_WEBDAV", "webdav:5232") args["HOST_WEBDAV"] = args.get("HOST_WEBDAV", "webdav:5232")
if args["WEBDAV"] != "none": if args["WEBDAV"] != "none":
args["HOST_WEBDAV"] = resolve(args.get("HOST_WEBDAV")) args["WEBDAV_ADDRESS"] = resolve(args.get("HOST_WEBDAV"))
# TLS configuration # TLS configuration
cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem") cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem")

@ -65,7 +65,7 @@ virtual_mailbox_maps = ${podop}mailbox
# Mails are transported if required, then forwarded to Dovecot for delivery # Mails are transported if required, then forwarded to Dovecot for delivery
relay_domains = ${podop}transport relay_domains = ${podop}transport
transport_maps = ${podop}transport transport_maps = ${podop}transport
virtual_transport = lmtp:inet:{{ HOST_LMTP }} virtual_transport = lmtp:inet:{{ LMTP_ADDRESS }}
# In order to prevent Postfix from running DNS query, enforce the use of the # In order to prevent Postfix from running DNS query, enforce the use of the
# native DNS stack, that will check /etc/hosts properly. # native DNS stack, that will check /etc/hosts properly.
@ -104,7 +104,7 @@ unverified_recipient_reject_reason = Address lookup failure
# Milter # Milter
############### ###############
smtpd_milters = inet:{{ HOST_ANTISPAM }} smtpd_milters = inet:{{ ANTISPAM_ADDRESS }}
milter_protocol = 6 milter_protocol = 6
milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen} milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}
milter_default_action = tempfail milter_default_action = tempfail

@ -28,8 +28,8 @@ def start_podop():
# Actual startup script # Actual startup script
os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("HOST_FRONT", "front")) os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("HOST_FRONT", "front"))
os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("HOST_ADMIN", "admin")) os.environ["ADMIN_ADDRESS"] = resolve(os.environ.get("HOST_ADMIN", "admin"))
os.environ["HOST_ANTISPAM"] = resolve(os.environ.get("HOST_ANTISPAM", "antispam:11332")) os.environ["ANTISPAM_ADDRESS"] = resolve(os.environ.get("HOST_ANTISPAM", "antispam:11332"))
os.environ["HOST_LMTP"] = resolve(os.environ.get("HOST_LMTP", "imap:2525")) os.environ["LMTP_ADDRESS"] = resolve(os.environ.get("HOST_LMTP", "imap:2525"))
for postfix_file in glob.glob("/conf/*.cf"): for postfix_file in glob.glob("/conf/*.cf"):
convert(postfix_file, os.path.join("/etc/postfix", os.path.basename(postfix_file))) convert(postfix_file, os.path.join("/etc/postfix", os.path.basename(postfix_file)))

@ -1 +1 @@
servers = "{{ HOST_REDIS }}"; servers = "{{ REDIS_ADDRESS }}";

@ -1 +1 @@
servers = "{{ HOST_REDIS }}"; servers = "{{ REDIS_ADDRESS }}";

@ -10,7 +10,7 @@ log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
# Actual startup script # Actual startup script
os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("HOST_FRONT", "front")) os.environ["FRONT_ADDRESS"] = resolve(os.environ.get("HOST_FRONT", "front"))
os.environ["HOST_REDIS"] = resolve(os.environ.get("HOST_REDIS", "redis")) os.environ["REDIS_ADDRESS"] = resolve(os.environ.get("HOST_REDIS", "redis"))
for rspamd_file in glob.glob("/conf/*"): for rspamd_file in glob.glob("/conf/*"):
convert(rspamd_file, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file))) convert(rspamd_file, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file)))

Loading…
Cancel
Save