docker-mailserver/target/bin/excluderelaydomain

20 lines
449 B
Plaintext
Raw Normal View History

#! /bin/bash
# shellcheck source=../bin-helper.sh
. /usr/local/bin/bin-helper.sh
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-relaymap.cf}
DOMAIN="${1}"
function usage { echo "Usage: excluderelayhost <domain>" ; }
[[ -z ${DOMAIN} ]] && { usage ; errex "no domain specified" ; }
if grep -qi "^@${DOMAIN}" "${DATABASE}" 2>/dev/null
then
sed -i "s/^@${DOMAIN}.*/@${DOMAIN}/" "${DATABASE}"
else
echo -e "@${DOMAIN}" >> "${DATABASE}"
fi