mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
29 lines
601 B
Plaintext
29 lines
601 B
Plaintext
|
#! /bin/bash
|
||
|
|
||
|
DATABASE=${DATABASE:-/tmp/docker-mailserver/dovecot-quotas.cf}
|
||
|
USER_DATABASE=${USER_DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
||
|
|
||
|
USER="$1"
|
||
|
|
||
|
usage() {
|
||
|
echo "Usage: delquota <username@domain>"
|
||
|
}
|
||
|
|
||
|
errex() {
|
||
|
echo "$@" 1>&2
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
escape() {
|
||
|
echo "${1//./\\.}"
|
||
|
}
|
||
|
|
||
|
[ -z "$USER" ] && { usage; errex "No username specified"; }
|
||
|
expr index "$USER" "@" >/dev/null || { 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
|