#! /usr/bin/env sh

sed -e "s/hosts *=.*/hosts = ${POSTGRES_HOST}/g" -i /etc/postfix/pgsql_*
sed -e "s/user *=.*/user = ${POSTGRES_USER}/g" -i /etc/postfix/pgsql_*
sed -e "s/password *=.*/password = ${POSTGRES_PASSWORD}/g" -i /etc/postfix/pgsql_*
sed -e "s/dbname *=.*/dbname = ${POSTGRES_DB}/g" -i /etc/postfix/pgsql_*

postconf -e mydomain="${MAIL_DOMAIN}"
postconf -e myhostname="${MAIL_HOSTNAME}"
postconf -e smtpd_sasl_path="inet:${DOVECOT_HOST}:${DOVECOT_SASL_PORT}"
postconf -e virtual_transport="lmtp:inet:${DOVECOT_HOST}:${DOVECOT_LMTP_PORT}"
postconf -e smtpd_milters="inet:${OPENDKIM_HOST}:${OPENDKIM_PORT}"
postconf -e non_smtpd_milters="inet:${OPENDKIM_HOST}:${OPENDKIM_PORT}"

rm -f /var/run/rsyslogd.pid
service rsyslog start &&
service postfix start &&

cat /var/log/mail.info
