major refactoring for setup.sh (#1590)#1595
major refactoring for setup.sh (#1590)#1595fbartels merged 5 commits intodocker-mailserver:masterfrom georglauterbach:master
Conversation
|
Thanks for reviving and completing my work from #1258 I did close this pr just now.
The main intention behind this is to force some "hygiene" when working with bash scripts. |
I would say it the other way around. If a step in between fails, but the script continues that could very much have unintentional side effects. But yes, forcing The concrete errors I see are: This indeed looks like its unrelated to your change. Not enough parameters left after this is the line of the tests https://github.com/tomav/docker-mailserver/blob/f225e14a219824e4ebb34e63b144e6d7c1314bcb/test/tests.bats#L1424-L1426. what happens when you manually run setup.sh with these parameters? |
`set -u` stopped dkim generation from defaulting
|
Seems like you mixed up line 279 with 297. The script fails because with 279 dkim ) _docker_image generate-dkim-config "${2:-2048}" ;;instead of just EDIT: current error not ok 268 checking setup.sh: setup.sh debug fetchmail
(in test file test/tests.bats, line 1426)
`[ "$status" -eq 11 ]' failedWill tend to it. EDIT2: I had a look at it, even tested it with my working mailserver instance and the $ ./setup.sh -c mail debug fetchmail
fetchmail: no mailservers have been specified.To me, this seems to be broken even before I refactored it. Is this even possible? |
|
Investigated error tracking. There was the idea of showing where an error was, and that there was an error. I tried set -euE
trap '_report_err() $LINENO' ERR
function _report_err()
{
echo "Error happened on line $1" | tee -a $LOG
}until I realized:
The first two are important (obviously). Unless we switch to a different interpreter (looking at you, |
|
Well, personally I wouldn't mind using bash. The setup script does run on the host though, so bash may not be available. In practice I haven't seen a Linux host without bash for ages, though. @fbartels what do you think? Upgrade to bash? |
In addition to the already mentioned points, |
|
Yes I agree. Almost every host (especially if its also running Docker) will have bash or something that provides the ability to interpret bash. So upgrading this helper script should be no problem. |
changed to bash and implemented simple error logging
|
Implemented the feature, but still: 268 is failing. EDIT2: Previous edit seemed wrong |
|
Yes, nevermind. My refactoring was incomplete. This should in practice work now. Can you approve @fbartels @erik-wramner ? |
|
@fbartels I am currently working on a bigger PR obsoleting #1228 and #1550 Therefore, I would like to know when this PR (#1595) is to be merged. I'd like to become a contributor to manage these PR's. But first, this and #1596 must be merged, as the new PR I'm currently working on is based on them. Do you have any information? What about @erik-wramner ? |
|
Usually I leave the merging to @erik-wramner, but you changes look good to me so I'll merge them in now. |
|
Image/Container name detection was removed. Was that on purpose? |
Not sure what you mean @casperklein, but looking at lines 186 ff. in |
|
You are absolutely right. I don't know, why I missed that. Sorry for the noise. |
Improvements for
setup.shFollowing #1590, I re-wrote and refactored
setup.shtoThis PR obsoletes #1258.
Rationale
Looking at #1258, I adopted some changes, namely
set -euand the use of default values. This PR has the podman changes already in it and does therefore not need to be rebased. Looking at the use ofset -eu, I am really not sure whether this is the best solution to be honest, and I would like to hear an opinion on this.Furthermore, I restructured the script, setting description and default values in the beginning, followed by all functions. I believe this to be more consistent.
I also included the changes to
README.mdto reflect what @fbartels already did in #1258.Disclaimer
Not sure whether I made (one or more) (minor / major) mistakes while refactoring. The test will show. Bash is still Bash in the end.