mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-02 00:54:54 +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
|
@ -1,7 +1,7 @@
|
|||
#! /bin/bash
|
||||
|
||||
# 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-virtual.cf}
|
||||
|
||||
|
@ -36,14 +36,14 @@ function __usage
|
|||
EMAIL="${1}"
|
||||
RECIPIENT="${2}"
|
||||
|
||||
[[ -z ${EMAIL} ]] && { __usage ; errex 'No alias specified' ; }
|
||||
[[ -z ${RECIPIENT} ]] && { __usage ; errex 'No recipient specified' ; }
|
||||
[[ -z ${EMAIL} ]] && { __usage ; _errex 'No alias specified' ; }
|
||||
[[ -z ${RECIPIENT} ]] && { __usage ; _errex 'No recipient specified' ; }
|
||||
|
||||
grep \
|
||||
-qi "^$(escape "${EMAIL}")[a-zA-Z@.\ ]*$(escape "${RECIPIENT}")" \
|
||||
"${DATABASE}" 2>/dev/null && errex "Alias \"${EMAIL} ${RECIPIENT}\" already exists"
|
||||
-qi "^$(_escape "${EMAIL}")[a-zA-Z@.\ ]*$(_escape "${RECIPIENT}")" \
|
||||
"${DATABASE}" 2>/dev/null && _errex "Alias \"${EMAIL} ${RECIPIENT}\" already exists"
|
||||
|
||||
if grep -qi "^$(escape "${EMAIL}")" "${DATABASE}" 2>/dev/null
|
||||
if grep -qi "^$(_escape "${EMAIL}")" "${DATABASE}" 2>/dev/null
|
||||
then
|
||||
sed -i "/${EMAIL}/s/$/,${RECIPIENT}/" "${DATABASE}"
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue