Fix checksum race condition in check-for-changes.sh

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.
This commit is contained in:
mwnx 2020-08-24 20:46:50 +02:00
parent f225e14a21
commit 2a70f33a4b
5 changed files with 39 additions and 32 deletions

View file

@ -73,3 +73,23 @@ for key, value in acme.items():
return 1
fi
}
# File storing the checksums of the monitored files.
CHKSUM_FILE=/tmp/docker-mailserver-config-chksum
# Compute checksums of monitored files.
function monitored_files_checksums() {
(
cd /tmp/docker-mailserver
# (2>/dev/null to ignore warnings about files that don't exist)
exec sha512sum 2>/dev/null -- \
postfix-accounts.cf \
postfix-virtual.cf \
postfix-aliases.cf \
dovecot-quotas.cf \
/etc/letsencrypt/acme.json \
"/etc/letsencrypt/live/$HOSTNAME/key.pem" \
"/etc/letsencrypt/live/$HOSTNAME/fullchain.pem"
)
return 0
}