10-postfix.sh
915 Bytes
#!/bin/bash
HOSTNAME=$(hostname -f)
postconf -e \
"myhostname = $HOSTNAME" \
"mydestination = $HOSTNAME, localhost.localdomain, localhost" \
"mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/8 172.0.0.0/8"\
"inet_protocols = all" \
"relayhost = $POSTFIX_RELAYHOST" \
"virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp" \
"home_mailbox = Maildir/" \
&& true
touch /etc/postfix/virtual
postmap /etc/postfix/virtual
if [[ $POSTFIX_REDIRECT_MAIL_LOCALHOST ]]; then
echo "/.+@.+/ $POSTFIX_REDIRECT_MAIL_LOCALHOST@localhost" > /etc/postfix/virtual-regexp
if ! getent passwd $POSTFIX_REDIRECT_MAIL_LOCALHOST > /dev/null; then
adduser --disabled-password --gecos "$POSTFIX_REDIRECT_MAIL_LOCALHOST" $POSTFIX_REDIRECT_MAIL_LOCALHOST
fi
echo "$POSTFIX_REDIRECT_MAIL_LOCALHOST:$POSTFIX_REDIRECT_MAIL_LOCALHOST" | chpasswd
else
: > /etc/postfix/virtual-regexp
fi