chore(housekeeping): Create helpers/change-detection.sh (#2610)

* chore: Extract change-detection method to it's own helper

This doesn't really belong in `helpers/ssl.sh`. Moving to it's own helper script.

* chore: Co-locate related change-detection method from container startup

It seems relevant to migrate the related support during startup for the change detection feature into this helper.

I opted to move the call from `start-mailserver.sh` into the `_setup` call at the end for a more explicit/visible location.

* chore: Move `CHKSUM_FILE` into `helpers/change-detection.sh`

It belongs there, not in `helpers/index.sh`.

* chore: Revise inline documentation

* tests(fix): Ensure correct functionality

Presently `test/test_helper.bats` is using it's own  `CHKSUM_FILE` instead of sourcing the var for the filepath.

`test_helper/common.bash` was calling a method to check for changes, but this helper may not correctly detect letsencrypt related changes as these are not ENV rely on, but global vars handled by `helpers/dns.sh`, so that should be run first like it is for `check-for-changes.sh`.

* tests(chore): Use `CHKSUM_FILE` var from helper

* chore: `addmailuser` should use `CHKSUM_FILE` var

* chore: Update `check-for-changes.sh` log message with correct path
This commit is contained in:
Brennan Kinney 2022-06-05 11:59:54 +12:00 committed by GitHub
parent 598aee166c
commit c862e1451d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 92 additions and 86 deletions

View file

@ -7,6 +7,9 @@ function _setup
do
${FUNC}
done
# All startup modifications to configs should have taken place before calling this:
_prepare_for_change_detection
}
function _setup_supervisor
@ -77,22 +80,6 @@ function _setup_file_permissions
chmod 640 /var/log/mail/freshclam.log
}
function _setup_chksum_file
{
_log 'debug' 'Setting up configuration checksum file'
if [[ -d /tmp/docker-mailserver ]]
then
_log 'trace' "Creating '${CHKSUM_FILE}'"
_monitored_files_checksums >"${CHKSUM_FILE}"
else
# We could just skip the file, but perhaps config can be added later?
# If so it must be processed by the check for changes script
_log 'trace' "Creating empty '${CHKSUM_FILE}' (no config)"
touch "${CHKSUM_FILE}"
fi
}
function _setup_mailname
{
_log 'debug' "Setting up mailname and creating '/etc/mailname'"