docker-mailserver/target/bin/excluderelaydomain

20 lines
483 B
Bash
Executable File

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