From b7e5d42e09587f707c8de4f45898fb93f41e42c9 Mon Sep 17 00:00:00 2001 From: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> Date: Sun, 15 May 2022 23:37:21 +0200 Subject: [PATCH] scripts: more consistency in `start-mailserver.sh` (#2587) * consistently name functions (starting with `_`) in `start-mailserver.sh` Most of the functions that execute the different stacks during startup were not prefixed with `_`, but all our other functions are. This has now been fixed. * cleanup in `start-mailserver.sh` I adjusted the comments for all sections in the start script so they are properly displayed again. --- target/scripts/start-mailserver.sh | 34 ++++++++++++++------------- target/scripts/startup/check-stack.sh | 2 +- target/scripts/startup/fixes-stack.sh | 2 +- target/scripts/startup/misc-stack.sh | 2 +- target/scripts/startup/setup-stack.sh | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/target/scripts/start-mailserver.sh b/target/scripts/start-mailserver.sh index cb5d2be5..a98a2081 100755 --- a/target/scripts/start-mailserver.sh +++ b/target/scripts/start-mailserver.sh @@ -1,5 +1,6 @@ #! /bin/bash +# ------------------------------------------------------------ # ? >> Sourcing helpers & stacks # 1. Helpers # 2. Checks @@ -27,24 +28,28 @@ source /usr/local/bin/misc-stack.sh # shellcheck source=./startup/daemons-stack.sh source /usr/local/bin/daemons-stack.sh +# ------------------------------------------------------------ +# ? << Sourcing helpers & stacks +# -- +# ? >> Setup Supervisor & DNS names # ------------------------------------------------------------ # Setup supervisord as early as possible declare -A VARS VARS[SUPERVISOR_LOGLEVEL]="${SUPERVISOR_LOGLEVEL:=warn}" + _setup_supervisor - -# shellcheck disable=SC2034 -declare -a FUNCS_SETUP FUNCS_FIX FUNCS_CHECK FUNCS_MISC DAEMONS_START - _obtain_hostname_and_domainname # ------------------------------------------------------------ -# ? << +# ? << Setup Supervisor & DNS names # -- # ? >> Setup of default and global values / variables # ------------------------------------------------------------ +# shellcheck disable=SC2034 +declare -a FUNCS_SETUP FUNCS_FIX FUNCS_CHECK FUNCS_MISC DAEMONS_START + # These variables must be defined first; They are used as default values for other variables. VARS[POSTMASTER_ADDRESS]="${POSTMASTER_ADDRESS:=postmaster@${DOMAINNAME}}" VARS[REPORT_RECIPIENT]="${REPORT_RECIPIENT:=${POSTMASTER_ADDRESS}}" @@ -117,7 +122,7 @@ VARS[VIRUSMAILS_DELETE_DELAY]="${VIRUSMAILS_DELETE_DELAY:=7}" # ? >> Registering functions # ------------------------------------------------------------ -function register_functions +function _register_functions { _log 'info' 'Initializing setup' _log 'debug' 'Registering functions' @@ -268,24 +273,21 @@ function _register_misc_function # ------------------------------------------------------------ # ? << Registering functions - -# ------------------------------------------------------------ -# ? << Sourcing all stacks # -- -# ? >> Executing all stacks +# ? >> Executing all stacks / actual start of DMS # ------------------------------------------------------------ _log 'info' "Welcome to docker-mailserver $(/CONTAINER_START _log 'info' "${HOSTNAME} is up and running" diff --git a/target/scripts/startup/check-stack.sh b/target/scripts/startup/check-stack.sh index aaab03d5..0560dd01 100644 --- a/target/scripts/startup/check-stack.sh +++ b/target/scripts/startup/check-stack.sh @@ -1,6 +1,6 @@ #! /bin/bash -function check +function _check { _log 'info' 'Checking configuration' for FUNC in "${FUNCS_CHECK[@]}" diff --git a/target/scripts/startup/fixes-stack.sh b/target/scripts/startup/fixes-stack.sh index 7a26c76e..c092a5f0 100644 --- a/target/scripts/startup/fixes-stack.sh +++ b/target/scripts/startup/fixes-stack.sh @@ -1,6 +1,6 @@ #! /bin/bash -function fix +function _apply_fixes { _log 'info' 'Post-configuration checks' for FUNC in "${FUNCS_FIX[@]}" diff --git a/target/scripts/startup/misc-stack.sh b/target/scripts/startup/misc-stack.sh index 979f4292..e88d358d 100644 --- a/target/scripts/startup/misc-stack.sh +++ b/target/scripts/startup/misc-stack.sh @@ -1,6 +1,6 @@ #! /bin/bash -function start_misc +function _start_misc { _log 'info' 'Starting miscellaneous tasks' for FUNC in "${FUNCS_MISC[@]}" diff --git a/target/scripts/startup/setup-stack.sh b/target/scripts/startup/setup-stack.sh index 56979936..40a86cd3 100644 --- a/target/scripts/startup/setup-stack.sh +++ b/target/scripts/startup/setup-stack.sh @@ -1,6 +1,6 @@ #! /bin/bash -function setup +function _setup { _log 'info' 'Configuring mail server' for FUNC in "${FUNCS_SETUP[@]}"