#! /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 " } 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