This repository has been archived on 2021-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
mail/postfix/postfix.sh
2018-03-24 17:52:46 +00:00

45 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
[ -e /etc/postfix/dh-params/512.pem ] || openssl gendh -out /etc/postfix/dh-params/512.pem -2 512
[ -e /etc/postfix/dh-params/2048.pem ] || openssl gendh -out /etc/postfix/dh-params/2048.pem -2 2048
postconf -e myhostname="$MYHOSTNAME"
postconf -e mydomain="$MYDOMAIN"
postconf -e mail_name="$MAIL_NAME"
postconf -e message_size_limit="$MESSAGE_SIZE_LIMIT"
postconf -e smtpd_tls_key_file="$TLS_KEY"
postconf -e smtpd_tls_cert_file="$TLS_FULLCHAIN"
postconf -e virtual_mailbox_domains="$DOMAINS"
for hash in access_recipient access_sender access_helo;do #virtual;do
touch /etc/postfix/$hash
postmap /etc/postfix/$hash
done
# set ldap search base
sed -i \
-e "s/@@SEARCH_BASE@@/${LDAP_BASE}/g" \
-e "s/@@SERVER_HOST@@/${LDAP_SERVER}/g" \
/etc/postfix/ldap/virtual_mailbox_maps.cf
# is cidr, so not included in the hash section
touch /etc/postfix/access_client
echo "MAILER-DAEMON: postmaster\npostmaster: $POSTMASTER" > /etc/postfix/aliases
newaliases
# is mounted, so no default structure
(
cd /var/spool/postfix
chown postfix:postfix .
for dir in active bounce corrupt defer deferred flush hold incoming maildrop pid private public saved trace; do
mkdir -p $dir
chown postfix:postfix $dir
done
)
exec /usr/lib/postfix/master -c /etc/postfix -d