docker-mailserver/target
Brennan Kinney 57aeb6db2a
refactor: CLI commands for database management (#2654)
See the associated PR for more detailed commentary on specific changes.

### Commands refactored:
- User (**All:** add / list / update / del + _dovecot-master variants_)
- Quota (**All:** set / del)
- Virtual Alias (**All:** add / list /del)
- Relay (**All:** add-relayhost / add-sasl / exclude-domain)

### Overall changes involve:
- **Fairly common structure:**
  - `_main` method at the top provides an overview of logical steps:
    - After all methods are declared beneath it (_and imported from the new `helpers/database/db.sh`_), the `_main` is called at the bottom of the file.
    - `delmailuser` additionally processes option support for `-y` prior to calling `_main`.
  - `__usage` is now consistent with each of these commands, along with the `help` command.
  - Most logic delegated to new helper scripts. Some duplicate content remains on the basis that it's low-risk to maintenance and avoids less hassle to jump between files to check a single line, usually this is arg validation.
  - Error handling should be more consistent, along with var names (_no more `USER`/`EMAIL`/`FULL_EMAIL` to refer to the same expected value_).
- **Three new management scripts** (in `helpers/database/manage/`) using a common structure for managing changes to their respective "Database" config file.
  - `postfix-accounts.sh` unified not only add and update commands, but also all the dovecot-master versions, a single password call for all 4 of them, with a 5th consumer of the password prompt from the relay command `addsaslpassword`.
  - These scripts delegate actual writes to `helpers/database/db.sh` which provides a common API to support the changes made.
     - This is more verbose/complex vs the current inline operations each command currently has, as it provides generic support instead of slightly different variations being maintained, along with handling some edge cases that existed and would lead to bugs (notably substring matches).
     - Centralizing changes here seems wiser than scattered about. I've tried to make it easy to grok, hopefully it's not worse than the current situation.
     - List operations were kept in their respective commands, `db.sh` is only really managing writes. I didn't see a nice way for removing the code duplication for list commands as the duplication was fairly minimal, especially for `listalias` and `listdovecotmasteruser` which were quite simple in their differences in the loop body.
     - `listmailuser` and `delmailuser` also retain methods exclusive to respective commands, I wasn't sure if there was any benefit to move those, but they were refactored.
2022-07-29 12:10:23 +12:00
..
amavis/conf.d Improve fail2ban docs and fix a typo (#2126) 2021-08-13 10:30:39 +02:00
bin refactor: CLI commands for database management (#2654) 2022-07-29 12:10:23 +12:00
docker-configomat@4155504854 Updated submodule target/docker-configomat 2020-10-11 19:41:53 +02:00
dovecot feat: Support for Dovecot master accounts (#2535) 2022-05-08 00:28:32 +02:00
fail2ban Add ban feature to fail2ban script (#2538) 2022-04-19 08:44:51 +00:00
fetchmail Implement fetchmail (#260) (#271) 2016-08-21 22:13:13 +02:00
logwatch Add logwatch maillog.conf file to support /var/log/mail/ (#2112) 2021-08-11 11:31:00 +02:00
opendkim Fixed KeyTable refile in opendkim.conf https://serverfault.com/a/861701/377751 (#2249) 2021-10-16 19:04:51 +02:00
opendmarc [opendmarc] Skip dmarc checks for email sent over authenticated sockets 2017-09-11 17:02:47 -07:00
postfix service(postfix): Better handling of the compatibility_level setting (#2597) 2022-06-05 12:10:20 +12:00
postgrey housekeeping 2020-11-06 14:04:23 +01:00
postsrsd formatting files according to standard (#1619) 2020-09-24 14:54:21 +02:00
scripts refactor: CLI commands for database management (#2654) 2022-07-29 12:10:23 +12:00
shared init tests cases ffdhe4096 2020-04-26 22:23:51 +02:00
supervisor Fix changedetector restart loop (#2548) 2022-04-19 21:09:25 +02:00