docker-mailserver/target/bin/delquota
Brennan Kinney 182b71d33f
chore: Drop setup.sh DATABASE fallback ENV (#2556)
* 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
2022-04-20 12:29:28 +12:00

23 lines
683 B
Bash
Executable file

#! /bin/bash
# shellcheck source=../scripts/helpers/index.sh
source /usr/local/bin/helpers/index.sh
DATABASE='/tmp/docker-mailserver/dovecot-quotas.cf'
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 ; _exit_with_error 'No username specified' ; }
[[ ${USER} =~ .*\@.* ]] || { __usage ; _exit_with_error 'Username must include the domain' ; }
grep -qE "^${USER}\|" "${USER_DATABASE}" || _exit_with_error "User '${USER}' does not exist"
[[ -s ${DATABASE} ]] || exit 0
sed -i -e "/^${USER}:.*$/d" "${DATABASE}"