docker-mailserver/target/scripts/helpers
Brennan Kinney 5b54d1d32e
refactor: `relay.sh` (#3845)
* chore: `relay.sh` helper - Reference user config paths via variables

* chore: Better document postfix helper `_vhost_collect_postfix_domains()`

The functionality is effectively the same for the two configs for the most part when it comes to parsing out a domain from the target value.

Virtual aliases is more flexible in value, which may not have a domain-part present (manual user edit).

* chore: `check-for-change.sh` - Support VHOST change visibility

- Moves the "handle changes" logic into it's own scoped function, out of the main change detection loop logic.
- This will be benefit a future commit change that will rely on `VHOST_UPDATED=1`.

* chore: `relay.sh` - Minor revisions to minimize diff noise

- Better phrasing of the current logic comments.
- Regex patterns assigned to variables (easier to grok intention)
- Bulk of the logic for generating `/etc/postfix/relayhost_map` wrapped into a separate function with Postfix config setting handled separately.

* refactor: `relay.sh` opt-out logic

- Split the two distinct features that configure `/etc/postfix/relayhost_map` into separate functions (_`MATCH_VALID` var no longer needed for legacy support_).
- Instead of extracting domains from `postfix-accounts.cf` + `postfix-virtual.cf`, this has already been handled at `/etc/postfix/vhost`, sourcing from there is far less complicated.
- Rename loop var `DOMAIN_PART`to `SENDER_DOMAIN` for better context of what it represents when appended to the config file.
- Revised maintenance notes + guidance towards a future refactor of this relayhost feature support.

* docs: `relay.sh` - Additional comment revisions

* feat: `DEFAULT_RELAY_HOST` can now also use relay credentials ENV

- Remove comment regarding `smtp_sasl_password_maps = static:${RELAY_USER}:${RELAY_PASSWORD}`, it could be used but `main.cf` presently has `644` permissions vs the `sasl_passwd` file permissions of `600`, less secure at preventing leaking of secrets (ignoring the ENV exposure itself).
- Move the `main.cf` settings specific to relayhost credentials support / security into to the relevant function scope instead. This also allows for the configuration to be applied by a change detection event without container restart requirement.
- Outer functions for setup and change detection to call have a clearer config dependency guard, as does the `_legacy_support()`.
- These changes now support `DEFAULT_RELAY_HOST` to leverage the relay credentials ENV as well.
- `DATABASE_RELAYHOSTS` is available in scope to the functions called here that reference it.

* docs: Revised ENV docs on relay host config

Better quality guidance on configuring relay hosts.

* chore: Add entry to `CHANGELOG.md`

* fix: `relay.sh` - `grep` regex compatibility with `+` requires `-E`

* chore: `postfix.sh` - `FIRST_FIELD` => More descriptive field name
2024-01-31 10:24:43 +13:00
..
database Change 'function' style (#3364) 2023-05-26 01:01:41 +02:00
accounts.sh fix: Ensure configs are sanitized for parsing (#3819) 2024-01-26 10:28:26 +13:00
aliases.sh fix: Ensure configs are sanitized for parsing (#3819) 2024-01-26 10:28:26 +13:00
change-detection.sh misc: final Rspamd adjustments for v13 (#3599) 2023-10-30 10:20:37 +01:00
dns.sh Change 'function' style (#3364) 2023-05-26 01:01:41 +02:00
error.sh Change 'function' style (#3364) 2023-05-26 01:01:41 +02:00
index.sh misc: final Rspamd adjustments for v13 (#3599) 2023-10-30 10:20:37 +01:00
lock.sh Change 'while' style (#3365) 2023-05-26 01:39:39 +02:00
log.sh Change 'function' style (#3364) 2023-05-26 01:01:41 +02:00
network.sh Change 'for' style (#3368) 2023-05-26 14:00:40 +02:00
postfix.sh refactor: `relay.sh` (#3845) 2024-01-31 10:24:43 +13:00
relay.sh refactor: `relay.sh` (#3845) 2024-01-31 10:24:43 +13:00
rspamd.sh Rspamd: only declare Rspamd variables when not already declared (#3837) 2024-01-26 14:07:46 +01:00
ssl.sh Change 'function' style (#3364) 2023-05-26 01:01:41 +02:00
utils.sh fix: Ensure configs are sanitized for parsing (#3819) 2024-01-26 10:28:26 +13:00