You've already forked docker-mailserver
mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-08 23:06:49 +02:00
chore(scripts): Removing flock so NFS works (#1980)
Co-authored-by: Casper <casperklein@users.noreply.github.com> Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
@ -35,31 +35,41 @@ function __usage
|
||||
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
|
||||
USER="${1}"
|
||||
FULL_EMAIL="${1}"
|
||||
shift
|
||||
PASSWD="${*}"
|
||||
|
||||
[[ -z ${USER} ]] && { __usage ; errex 'No username specified' ; }
|
||||
[[ "${USER}" =~ .*\@.* ]] || { __usage ; errex 'Username must include the domain' ; }
|
||||
[[ -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}"
|
||||
(
|
||||
flock -e 200
|
||||
create_lock "$(basename "$0")"
|
||||
if grep -qi "^$(escape "${FULL_EMAIL}")|" "${DATABASE}"
|
||||
then
|
||||
echo "User '${FULL_EMAIL}' already exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -qi "^$(escape "${USER}")|" "${DATABASE}" 2>/dev/null
|
||||
then
|
||||
echo "User '${USER}' already exists."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z ${PASSWD} ]]
|
||||
then
|
||||
read -r -s -p "Enter Password: " PASSWD
|
||||
echo
|
||||
[[ -z ${PASSWD} ]] && errex "Password must not be empty"
|
||||
fi
|
||||
|
||||
if [[ -z ${PASSWD} ]]
|
||||
then
|
||||
read -r -s -p "Enter Password: " PASSWD
|
||||
echo
|
||||
[[ -z ${PASSWD} ]] && errex "Password must not be empty"
|
||||
fi
|
||||
HASH="$(doveadm pw -s SHA512-CRYPT -u "${FULL_EMAIL}" -p "${PASSWD}")"
|
||||
echo "${FULL_EMAIL}|${HASH}" >> "${DATABASE}"
|
||||
|
||||
HASH="$(doveadm pw -s SHA512-CRYPT -u "${USER}" -p "${PASSWD}")"
|
||||
echo "${USER}|${HASH}" >> "${DATABASE}"
|
||||
) 200< "${DATABASE}"
|
||||
USER="${FULL_EMAIL%@*}"
|
||||
DOMAIN="${FULL_EMAIL#*@}"
|
||||
|
||||
# Tests fail if the creation of /var/mail/${DOMAIN}/${USER} doesn't happen fast enough after addmailuser executes (check-for-changes.sh race-condition)
|
||||
if [[ -e "/tmp/docker-mailserver-config-chksum" ]] # Prevent infinite loop in tests like "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf even when that file does not exist"
|
||||
then
|
||||
while [[ ! -d "/var/mail/${DOMAIN}/${USER}" ]]
|
||||
do
|
||||
echo "Waiting for dovecot to create /var/mail/${DOMAIN}/${USER}..."
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
Reference in New Issue
Block a user