WIP: Refactord all scripts, adding shellcheck to travis; refactoring a few other files on the fly#1599
WIP: Refactord all scripts, adding shellcheck to travis; refactoring a few other files on the fly#1599georglauterbach wants to merge 20 commits intodocker-mailserver:masterfrom georglauterbach:shellcheck
Conversation
`set -u` stopped dkim generation from defaulting
changed to bash and implemented simple error logging
fixed $VOLUME not being set and refactored README as well due to markdownlint showing (valid) complaints
If a change to one of the tracked files happened soon after (<1 second?) a previously detected change, it could end up going undetected. In particular, this could cause integration tests to fail (see next commits). Fixed by computing the new checksum file _before_ checking for changes.
check-for-changes.sh did not have a special case to handle lines in postfix-relaymap.cf consisting of only a domain (indicating that said domain should never be relayed). This case is handled by start-mailserver.sh so when such a line existed, things would work well until a config file update was detected by check-for-changes.sh. After that, the generated relayhost_map file would be corrupted. Fixed by factoring a 'populate_relayhost_map' function out of start-mailserver.sh and into helper_functions.sh and reusing it in check-for-changes.sh. Note: There are certainly quite a few more pieces of code that could be refactored in a similar fashion. Note2: check-for-changes.sh would previously never update the relayhost_map file when $ENABLE_LDAP was set to 1. I don't think this was intended —there is after all no such condition in start-mailserver.sh— and so this condition no longer applies.
Previously, only postfix-relaymap.cf and postfix-accounts.cf would be used to populate the relayhost_map file. Now, also use postfix-virtual.cf when present. To me, there is nothing absurd about sending mail "From:" a virtual account (or more specifically its domain) so it makes sense that when a $RELAY_HOST is defined it should be used for virtual accounts as well.
setup.sh more consistent with braces, return codes, un-setting of variables and error reports and (importantly) test
checked and streamlined fail2ban and postfix wrapper
Relayhostmap from virtual
|
I really appreciate all the work you have put into this and it is absolutely worthwhile. However, based on previous similar attempts that have lost speed after a while and our limited review capacity I would suggest splitting the massive PR into many small parts, where we can merge and get the benefits from one change without having to wait for all of them to go through. That is just a suggestion. I'll get around to this eventually regardless, but I'm short on time as always and it tends to be easier to merge many small changes on at a time. |
|
@erik-wramner You're right. I came up with this: All changes not related to |
|
PS: I read about the limited review capacity. I'd like to help there, but I'd need to be a collaborator for this (or don't I?). What can we do abut this? |
|
It is merged now. You would need access from @tomav to actually do merges, but you're welcome to help with reviews of other PRs if you like. Not to mention answering questions, that is where I spend the bulk of my time. |
|
How would I go about contacting @tomav, @erik-wramner ? My rationale is this: I'm using the server and wan't it to be stable. Therefore I'd like to collaborate, answer questions and review/manager PRs :) |
|
Closing this PR as #1601 will come up soon. |
|
@aendeavor thanks for this very good work and welcome onboard! |
This is a bigger one
This was a lot of work. Please consider this before arguing. I know it's kind of big, but I think it's worth the hassle.
First things first
Help needed
The current problem I'm working on arises from a (locally executed) test:
This is kind of ridiculous:
Using this function locally works perfect. The use of
mapfile -d '.' ...in other places does not seem to throw an error. This seems to be related with the version of Bash used**?** I'm on Bash 5.0.17.I would like to receive some help here.
This is rather interesting: I do not get this error locally too.
Changes & Rationale
I made this PR to include
shellcheckand to make all the scripts more robust. I believe the latter to be especially important. Therefore, I refactored all scripts undertarget/(which was a lot of work). I furthermore extendedCONTRIBUTING.mdwith necessary coding style guidelines, and linking to it fromREADME. This accounts for the biggest portion of this PR.Travis should now use the shellcheck option and apply it via make.
I refactored the
Makefiletoo, to make it verbose where it should be, and less verbose where it's appropriate.Important
I'd really like to see some contributions in the form of either objective opinions or (better :D) code contributions to fix possible errors.