2018-04-02 08:45:58 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2022-02-21 10:56:57 +00:00
|
|
|
# shellcheck source=../scripts/helpers/index.sh
|
|
|
|
source /usr/local/bin/helpers/index.sh
|
2018-04-02 08:45:58 +00:00
|
|
|
|
2022-04-20 00:29:28 +00:00
|
|
|
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
|
|
|
|
2022-03-26 08:30:09 +00:00
|
|
|
function __usage { echo 'Usage: excluderelayhost <domain>' ; }
|
2018-04-02 08:45:58 +00:00
|
|
|
|
2022-03-26 08:30:09 +00:00
|
|
|
[[ -z ${DOMAIN} ]] && { __usage ; _exit_with_error "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
|