1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-22 02:17:26 +00:00

suppress some status output regarding new automatic aliases on first installation

This commit is contained in:
Joshua Tauberer 2015-08-19 16:30:32 -04:00
parent cfc4e6b48b
commit a8074ae3e4
2 changed files with 8 additions and 7 deletions

View File

@ -558,7 +558,8 @@ def kick(env, mail_result=None):
# Ensure every required alias exists. # Ensure every required alias exists.
existing_users = get_mail_users(env) existing_users = get_mail_users(env)
existing_aliases = get_mail_aliases(env) existing_alias_records = get_mail_aliases(env)
existing_aliases = set(a for a, *_ in existing_alias_records) # just first entry in tuple
required_aliases = get_required_aliases(env) required_aliases = get_required_aliases(env)
def ensure_admin_alias_exists(address): def ensure_admin_alias_exists(address):
@ -566,15 +567,15 @@ def kick(env, mail_result=None):
if address in existing_users: if address in existing_users:
return return
# Does this alias exists? # If the alias already exists, we're good.
for a, *_ in existing_aliases: if address in existing_aliases:
if a == address: return
return
# Doesn't exist. # Doesn't exist.
administrator = get_system_administrator(env) administrator = get_system_administrator(env)
if address == administrator: return # don't make an alias from the administrator to itself --- this alias must be created manually if address == administrator: return # don't make an alias from the administrator to itself --- this alias must be created manually
add_mail_alias(address, administrator, "", env, do_kick=False) add_mail_alias(address, administrator, "", env, do_kick=False)
if administrator not in existing_aliases: return # don't report the alias in output if the administrator alias isn't in yet -- this is a hack to supress confusing output on initial setup
results.append("added alias %s (=> %s)\n" % (address, administrator)) results.append("added alias %s (=> %s)\n" % (address, administrator))
for address in required_aliases: for address in required_aliases:
@ -582,7 +583,7 @@ def kick(env, mail_result=None):
# Remove auto-generated postmaster/admin on domains we no # Remove auto-generated postmaster/admin on domains we no
# longer have any other email addresses for. # longer have any other email addresses for.
for address, forwards_to, *_ in existing_aliases: for address, forwards_to, *_ in existing_alias_records:
user, domain = address.split("@") user, domain = address.split("@")
if user in ("postmaster", "admin") \ if user in ("postmaster", "admin") \
and address not in required_aliases \ and address not in required_aliases \

View File

@ -53,5 +53,5 @@ if [ -z "`tools/mail.py user`" ]; then
hide_output tools/mail.py user make-admin $EMAIL_ADDR hide_output tools/mail.py user make-admin $EMAIL_ADDR
# Create an alias to which we'll direct all automatically-created administrative aliases. # Create an alias to which we'll direct all automatically-created administrative aliases.
tools/mail.py alias add administrator@$PRIMARY_HOSTNAME $EMAIL_ADDR tools/mail.py alias add administrator@$PRIMARY_HOSTNAME $EMAIL_ADDR > /dev/null
fi fi