Add the email need: each app gets its own sending-only mail account
needs = ["email"] (coreapp new --email) makes an LDAP account coreapp-<name> (not a person, no mailbox) and adds SMTP_* settings. Teardown removes it only if it's the app's; the installer warns about an entry it left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -67,7 +67,7 @@ FIRST, LAST = 2, 254
|
||||
RESERVED = {"www", "mail", "ns1", "ns2", "autodiscover", "autoconfig",
|
||||
"panel", "dashboard", "mcphub", "api", "admin"}
|
||||
# What an app can ask for, in the order they're set up
|
||||
NEEDS = ["postgres", "sso"]
|
||||
NEEDS = ["postgres", "sso", "email"]
|
||||
|
||||
# What coreapp.toml may contain. Values end up in shell-sourced and YAML
|
||||
# files on the Core, so each is limited to characters that are safe there.
|
||||
@@ -768,6 +768,7 @@ def install_app(m, p, folder, origin, addon_ok, recreate):
|
||||
compose_up(m, log, recreate)
|
||||
|
||||
wait_until_answering(m, p)
|
||||
check_needs(m)
|
||||
if p["state"] == "update":
|
||||
remove_old_images(m)
|
||||
say(f"{'Installed' if p['state'] == 'new' else 'Updated'}: {p['url']}")
|
||||
@@ -797,6 +798,20 @@ def remove_images(image, keep=None):
|
||||
run(["docker", "image", "rm", f"{short_name(image)}:{tag}"])
|
||||
|
||||
|
||||
def check_needs(m):
|
||||
"""Say so if a need couldn't be set up (its setup only writes to the
|
||||
Core's install log)."""
|
||||
if "email" in m["needs"]:
|
||||
out = run(["bash", "-c", (
|
||||
'B=$(sed -n "s/^LDAP_SEARCH_BASE=ou=people,//p" /federated/apps/mail/.env); '
|
||||
'docker exec ldap ldapsearch -LLL -x -H ldap://localhost -D "cn=admin,$B" '
|
||||
'-w "$(cat /federated/apps/ldap/.ldap.secret)" '
|
||||
f'-b "uid=coreapp-{m["name"]},ou=people,$B" -s base description')])
|
||||
if f"description: coreapps: {m['name']}" not in out.stdout:
|
||||
say(f"Warning: {m['name']} can't send mail: LDAP has another entry with uid "
|
||||
f"coreapp-{m['name']} (or its address), which was left alone.")
|
||||
|
||||
|
||||
def remove_old_images(m):
|
||||
"""The app's images with other versions, now that this one runs."""
|
||||
remove_images(m["image"], keep=m["version"])
|
||||
|
||||
Reference in New Issue
Block a user