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