1
0
mirror of https://github.com/docker-mailserver/docker-mailserver.git synced 2025-08-08 23:06:49 +02: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:
Nathan Pierce
2021-09-13 04:09:01 -04:00
committed by GitHub
parent f8a621dadb
commit be35d9bef1
11 changed files with 172 additions and 37 deletions

View File

@ -42,9 +42,8 @@ PASSWD="${*}"
[[ -z ${FULL_EMAIL} ]] && { __usage ; errex 'No username specified' ; }
[[ "${FULL_EMAIL}" =~ .*\@.* ]] || { __usage ; errex 'Username must include the domain' ; }
# Protect config file with lock to avoid race conditions
touch "${DATABASE}"
create_lock "$(basename "$0")"
create_lock # Protect config file with lock to avoid race conditions
if grep -qi "^$(escape "${FULL_EMAIL}")|" "${DATABASE}"
then
echo "User '${FULL_EMAIL}' already exists."

View File

@ -86,7 +86,8 @@ then
fi
fi
create_lock "$(basename "$0")"
create_lock # Protect config file with lock to avoid race conditions
for EMAIL in "${@}"
do
ERROR=false

View File

@ -32,8 +32,7 @@ then
errex "invalid quota format. e.g. 302M (B (byte), k (kilobyte), M (megabyte), G (gigabyte) or T (terabyte))"
fi
# Protect config file with lock to avoid race conditions
create_lock "$(basename "$0")"
create_lock # Protect config file with lock to avoid race conditions
touch "${DATABASE}"
if [ -z "${QUOTA}" ]; then

View File

@ -27,8 +27,7 @@ fi
HASH="$(doveadm pw -s SHA512-CRYPT -u "${USER}" -p "${PASSWD}")"
# Protect config file with lock to avoid race conditions
touch "${DATABASE}"
create_lock "$(basename "$0")"
create_lock # Protect config file with lock to avoid race conditions
grep -qi "^$(escape "${USER}")|" "${DATABASE}" 2>/dev/null || errex "User \"${USER}\" does not exist"
sed -i "s ^""${USER}""|.* ""${USER}""|""${HASH}"" " "${DATABASE}"