docker-mailserver/target/bin/delmailuser

25 lines
406 B
Plaintext
Raw Normal View History

#! /bin/bash
2016-06-14 11:16:11 +00:00
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
2016-06-14 11:16:11 +00:00
USER="$1"
usage() {
echo "Usage: delmailuser <user@domain>"
}
errex() {
echo "$@" 1>&2
exit 1
2016-06-14 11:16:11 +00:00
}
escape() {
echo "${1//./\\.}"
}
[ -z "$USER" ] && { usage; errex "No user specifed"; }
[ -s "$DATABASE" ] || exit 0
# XXX $USER must not contain /s and other syntactic characters
sed -i "/^$(escape "$USER")|/d" $DATABASE