1
0
mirror of https://github.com/tomav/docker-mailserver.git synced 2024-07-03 14:41:10 +02:00
docker-mailserver/target/bin/excluderelaydomain
2022-03-21 15:01:07 +01:00

20 lines
479 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