mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-02 17:14:31 +02:00
refactoring: split helper functions into smaller scripts (#2420)
This commit is contained in:
parent
2927cc47c7
commit
b61dfe1e24
41 changed files with 389 additions and 396 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
# shellcheck disable=SC2094
|
||||
|
||||
# shellcheck source=../scripts/helper-functions.sh
|
||||
. /usr/local/bin/helper-functions.sh
|
||||
# shellcheck source=../scripts/helpers/index.sh
|
||||
source /usr/local/bin/helpers/index.sh
|
||||
|
||||
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
||||
|
||||
|
@ -39,12 +39,12 @@ FULL_EMAIL="${1}"
|
|||
shift
|
||||
PASSWD="${*}"
|
||||
|
||||
[[ -z ${FULL_EMAIL} ]] && { __usage ; errex 'No username specified' ; }
|
||||
[[ ${FULL_EMAIL} =~ .*\@.* ]] || { __usage ; errex 'Username must include the domain' ; }
|
||||
[[ -z ${FULL_EMAIL} ]] && { __usage ; _errex 'No username specified' ; }
|
||||
[[ ${FULL_EMAIL} =~ .*\@.* ]] || { __usage ; _errex 'Username must include the domain' ; }
|
||||
|
||||
touch "${DATABASE}"
|
||||
create_lock # Protect config file with lock to avoid race conditions
|
||||
if grep -qi "^$(escape "${FULL_EMAIL}")|" "${DATABASE}"
|
||||
_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."
|
||||
exit 1
|
||||
|
@ -54,7 +54,7 @@ if [[ -z ${PASSWD} ]]
|
|||
then
|
||||
read -r -s -p "Enter Password: " PASSWD
|
||||
echo
|
||||
[[ -z ${PASSWD} ]] && errex "Password must not be empty"
|
||||
[[ -z ${PASSWD} ]] && _errex "Password must not be empty"
|
||||
fi
|
||||
|
||||
HASH="$(doveadm pw -s SHA512-CRYPT -u "${FULL_EMAIL}" -p "${PASSWD}")"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue