This commit is contained in:
Thomas VIAL 2016-04-21 01:08:14 +02:00
parent a2109ff287
commit b58d0d33d6
13 changed files with 47 additions and 51 deletions

View file

@ -1,10 +1,12 @@
#!/bin/sh
touch /tmp/vhost.tmp
# Getting domains from mail accounts
while IFS=$'|' read login pass
do
domain=$(echo ${login} | cut -d @ -f2)
echo ${domain} >> /tmp/docker-mailserver/tmp/vhost.tmp
echo ${domain} >> /tmp/vhost.tmp
done < /tmp/docker-mailserver/postfix-accounts.cf
# Getting domains from mail aliases
@ -14,15 +16,15 @@ do
uname=$(echo ${from} | cut -d @ -f1)
domain=$(echo ${from} | cut -d @ -f2)
# if they are equal it means the line looks like: "user1 other@domain.tld"
test "$uname" != "$domain" && echo ${domain} >> /tmp/docker-mailserver/tmp/vhost.tmp
test "$uname" != "$domain" && echo ${domain} >> /tmp/vhost.tmp
done < /tmp/docker-mailserver/postfix-virtual.cf
# Keeping unique entries
if [ -f /tmp/docker-mailserver/tmp/vhost.tmp ]; then
cat /tmp/docker-mailserver/tmp/vhost.tmp | sort | uniq > /etc/postfix/vhost && rm /tmp/docker-mailserver/tmp/vhost.tmp
if [ -f /tmp/vhost.tmp ]; then
cat /tmp/vhost.tmp | sort | uniq > /tmp/vhost && rm /tmp/vhost.tmp
fi
grep -vE '^(\s*$|#)' /etc/postfix/vhost | while read domainname; do
grep -vE '^(\s*$|#)' /tmp/vhost | while read domainname; do
mkdir -p /tmp/docker-mailserver/opendkim/keys/$domainname
if [ ! -f "/tmp/docker-mailserver/opendkim/keys/$domainname/mail.private" ]; then
@ -53,3 +55,10 @@ grep -vE '^(\s*$|#)' /etc/postfix/vhost | while read domainname; do
fi
done
# Creates TrustedHosts if missing
if [ ! -f "/tmp/docker-mailserver/opendkim/TrustedHosts" ]; then
echo "Creating DKIM TrustedHosts";
echo "127.0.0.1" > /tmp/docker-mailserver/opendkim/TrustedHosts
echo "localhost" >> /tmp/docker-mailserver/opendkim/TrustedHosts
fi