mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
d46e094280
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
27 lines
698 B
Bash
Executable file
27 lines
698 B
Bash
Executable file
#! /bin/bash
|
|
|
|
# shellcheck source=../scripts/helper-functions.sh
|
|
. /usr/local/bin/helper-functions.sh
|
|
|
|
DATABASE=${DATABASE:-/tmp/docker-mailserver/dovecot-quotas.cf}
|
|
USER_DATABASE=${USER_DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
|
|
|
function __usage { echo "Usage: delquota <username@domain>" ; }
|
|
|
|
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
|
|
|
USER="${1}"
|
|
|
|
[[ -z ${USER} ]] && { __usage ; errex "No username specified" ; }
|
|
[[ ${USER} =~ .*\@.* ]] || { __usage ; errex "Username must include the domain"; }
|
|
|
|
if ! grep -qE "^${USER}\|" "${USER_DATABASE}"
|
|
then
|
|
__usage
|
|
errex "user ${USER} does not exist"
|
|
fi
|
|
|
|
[[ -s ${DATABASE} ]] || exit 0
|
|
|
|
sed -i -e "/^${USER}:.*$/d" "${DATABASE}"
|