#!/usr/bin/env bash

TIP_FILE="/root/iRedMail/iRedMail.tips"

${CMD_SED} "s#PH_FIRST_MAIL_DOMAIN#${FIRST_MAIL_DOMAIN}#g" ${TIP_FILE}
${CMD_SED} "s#PH_FIRST_DOMAIN_ADMIN_PASSWORD#${FIRST_DOMAIN_ADMIN_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_HOSTNAME#${HOSTNAME}#g" ${TIP_FILE}
${CMD_SED} "s#PH_MYSQL_ROOT_PASSWORD#${MYSQL_ROOT_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_VMAIL_DB_PASSWORD#${VMAIL_DB_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_VMAIL_DB_ADMIN_PASSWORD#${VMAIL_DB_ADMIN_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_AMAVISD_DB_PASSWORD#${AMAVISD_DB_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_IREDAPD_DB_PASSWORD#${IREDAPD_DB_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_IREDADMIN_DB_PASSWORD#${IREDADMIN_DB_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_FAIL2BAN_DB_PASSWORD#${FAIL2BAN_DB_PASSWORD}#g" ${TIP_FILE}
${CMD_SED} "s#PH_SA_BAYES_DB_PASSWORD#${SA_BAYES_DB_PASSWORD}#g" ${TIP_FILE}

if [ X"${MAIL_THE_TIP_FILE}" == X'YES' ]; then
    # Send in background and not hang the whole startup process.
    mail -s "Details of this iRedMail container" ${POSTMASTER_EMAIL} < ${TIP_FILE} &
fi
