2020-04-24 12:55:32 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
# shellcheck source=../bin-helper.sh
|
|
|
|
. /usr/local/bin/bin-helper.sh
|
|
|
|
|
2020-04-24 12:55:32 +00:00
|
|
|
DATABASE=${DATABASE:-/tmp/docker-mailserver/dovecot-quotas.cf}
|
|
|
|
USER_DATABASE=${USER_DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
USER="${1}"
|
2020-04-24 12:55:32 +00:00
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
function usage { echo "Usage: delquota <username@domain>" ; }
|
2020-04-24 12:55:32 +00:00
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
[[ -z ${USER} ]] && { usage ; errex "No username specified" ; }
|
|
|
|
[[ "${USER}" =~ .*\@.* ]] || { usage ; errex "username must include the domain"; }
|
2020-04-24 12:55:32 +00:00
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
if ! grep -qE "^${USER}\|" "${USER_DATABASE}"
|
|
|
|
then
|
|
|
|
usage
|
|
|
|
errex "user ${USER} does not exist"
|
2020-04-24 12:55:32 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
[[ -s ${DATABASE} ]] || exit 0
|
|
|
|
|
|
|
|
sed -i -e "/^${USER}:.*$/d" "${DATABASE}"
|