mirror of
https://github.com/tomav/docker-mailserver
synced 2025-09-03 15:55:24 +00:00
Lock file create and remove improvements (#2183)
* changed the locking function to better support multiple servers running at once and sharing the same config * helper function testing now runs inside of container Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
@@ -6,8 +6,6 @@
|
||||
LOG_DATE=$(date +"%Y-%m-%d %H:%M:%S ")
|
||||
_notify 'task' "${LOG_DATE} Start check-for-changes script."
|
||||
|
||||
SCRIPT_NAME="$(basename "$0")"
|
||||
|
||||
# ? ––––––––––––––––––––––––––––––––––––––––––––– Checks
|
||||
|
||||
cd /tmp/docker-mailserver || exit 1
|
||||
@@ -40,9 +38,6 @@ while true
|
||||
do
|
||||
LOG_DATE=$(date +"%Y-%m-%d %H:%M:%S ")
|
||||
|
||||
# Lock configuration while working
|
||||
create_lock "${SCRIPT_NAME}"
|
||||
|
||||
# get chksum and check it, no need to lock config yet
|
||||
_monitored_files_checksums >"${CHKSUM_FILE}.new"
|
||||
cmp --silent -- "${CHKSUM_FILE}" "${CHKSUM_FILE}.new"
|
||||
@@ -53,6 +48,7 @@ do
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
_notify 'inf' "${LOG_DATE} Change detected"
|
||||
create_lock # Shared config safety lock
|
||||
CHANGED=$(grep -Fxvf "${CHKSUM_FILE}" "${CHKSUM_FILE}.new" | sed 's/^[^ ]\+ //')
|
||||
|
||||
# Bug alert! This overwrites the alias set by start-mailserver.sh
|
||||
@@ -227,11 +223,12 @@ s/$/ regexp:\/etc\/postfix\/regexp/
|
||||
|
||||
# prevent restart of dovecot when smtp_only=1
|
||||
[[ ${SMTP_ONLY} -ne 1 ]] && supervisorctl restart dovecot
|
||||
|
||||
remove_lock
|
||||
fi
|
||||
|
||||
# mark changes as applied
|
||||
mv "${CHKSUM_FILE}.new" "${CHKSUM_FILE}"
|
||||
remove_lock "${SCRIPT_NAME}"
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
Reference in New Issue
Block a user