mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
182b71d33f
* chore: Remove `DATABASE` fallback ENV This was introduced without any mention or need, thus removing until a real use-case requires it. * chore: Remove `USER_DATABASE` fallback ENV Likewise, nothing requires this to be customizable. * chore: Consistently use single quote strings
24 lines
647 B
Bash
Executable file
24 lines
647 B
Bash
Executable file
#! /bin/bash
|
|
|
|
# shellcheck source=../scripts/helpers/index.sh
|
|
source /usr/local/bin/helpers/index.sh
|
|
|
|
DATABASE='/tmp/docker-mailserver/postfix-virtual.cf'
|
|
|
|
EMAIL="${1}"
|
|
RECIPIENT="${2}"
|
|
|
|
function __usage { echo "Usage: delalias <alias@domain> <recipient@other>" ; }
|
|
|
|
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
|
|
|
[[ -z ${EMAIL} ]] && { __usage ; _exit_with_error 'No alias specified' ; }
|
|
[[ -z ${RECIPIENT} ]] && { __usage ; _exit_with_error 'No recipient specified' ; }
|
|
[[ -s ${DATABASE} ]] || exit 0
|
|
|
|
sed -i \
|
|
-e "/^${EMAIL} *${RECIPIENT}$/d" \
|
|
-e "/^${EMAIL}/s/,${RECIPIENT}//g" \
|
|
-e "/^${EMAIL}/s/${RECIPIENT},//g" \
|
|
"${DATABASE}"
|