Skip to content

Restructure start-mailserver.sh #338#393

Merged
tomav merged 1 commit intodocker-mailserver:masterfrom
alinmear:master
Dec 17, 2016
Merged

Restructure start-mailserver.sh #338#393
tomav merged 1 commit intodocker-mailserver:masterfrom
alinmear:master

Conversation

@alinmear
Copy link
Copy Markdown
Contributor

@alinmear alinmear commented Dec 1, 2016

To make it easier to extend and maintain the logics of initialization of the mailserver and it's components i restructured the whole script into small junks/functions.

Let me explain the logics here:
We have 5 steps to bring the mailserver up (they are running after one another) :

  1. Check: these are functions to check the configuration sanity of the setup
  2. Setup: here happens the main configuration initialization.
  3. Fix: within this section we place proper fixes for problems that may occur (like permissions of the maildirs)
  4. Misc: within this section we can place functions that needs to be run before starting the daemons (like saving the container state)
  5. Start: within this section all daemon processes getting started

I also made a simple registration logic, for integrating new features easily:

  • Step 1: Find the section where to place a feature
  • Step 2: Implement the feature within the proper part of the script
  • Step 3: register the function at the top of the script (also within the proper section)

Integrating Checks and improve this pull request:
While making integration tests one of the things i recognized was, that we are lacking checks, when a setup step is not performed successfully (for this see my TODOs within the script). Because while executing the 5 steps (check, setup, fix, misc, start-daemons) i implemented to check for a proper return value. right now when there is an error while executing a script the return value $? != 0 --> execution part failed --> script becomes defunc state.

This can be the starting point to make proper checks within each part of the script. If this is not wanted, we should comment out the check whether a function return 0 or not.

Global and Default Vars:
On top of the script i made an associative array to place global variables. the _setup_default_vars() function loops over this array and exports the variable. With this we can define Default/Global Variables easily without having to mess around.

Improvements are welcome!

@tomav
Copy link
Copy Markdown
Contributor

tomav commented Dec 17, 2016

Hi @alinmear, I think it's a pretty good start.
I'm gonna merge it and we'll discuss about improvements.

@tomav tomav merged commit 00f8bdb into docker-mailserver:master Dec 17, 2016
@tomav
Copy link
Copy Markdown
Contributor

tomav commented Dec 17, 2016

@alinmear could you open an issue with suggested improvements? Thank you.

RichardFevrier pushed a commit to RichardFevrier/docker-mailserver that referenced this pull request Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants