OpenDKIM keys have been moved to the keys folder

This is to make it easier to integrate with Kubernetes to be able
to bind a `ConfigMap` to the said folder.
This commit is contained in:
Bojan Čekrlić 2019-02-19 11:42:16 +01:00
parent afccfdb3fc
commit 38d7627d96
5 changed files with 6 additions and 9 deletions

View file

@ -145,16 +145,13 @@ You'll need to create a folder for every domain you want to send through Postfi
``` ```
mkdir -p /host/keys; cd /host/keys mkdir -p /host/keys; cd /host/keys
mkdir example.com; cd example.com opendkim-genkey -b 2048 -h rsa-sha256 -r -v -s example.com -d example.com
opendkim-genkey -s mail -d example.com opendkim-genkey -b 2048 -h rsa-sha256 -r -v -s example.org -d example.org
cd ..
mkdir example.org; cd example.org
opendkim-genkey -s mail -d example.org
``` ```
`opendkim-genkey` is usually in your favourite distribution provided by installing `opendkim-tools` or `opendkim-utils`. `opendkim-genkey` is usually in your favourite distribution provided by installing `opendkim-tools` or `opendkim-utils`.
Add the created `mail.txt` files to your DNS record. Afterwards, just mount `/etc/opendkim/keys` into your image and DKIM Add the created `<domain>.txt` files to your DNS records. Afterwards, just mount `/etc/opendkim/keys` into your image and DKIM
will be used automatically, e.g.: will be used automatically, e.g.:
``` ```
docker run --rm --name postfix -e "ALLOWED_SENDER_DOMAINS=example.com example.org" -v /host/keys:/etc/opendkim/keys -p 1587:587 boky/postfix docker run --rm --name postfix -e "ALLOWED_SENDER_DOMAINS=example.com example.org" -v /host/keys:/etc/opendkim/keys -p 1587:587 boky/postfix

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
if [ ! -d /etc/opendkim/keys ]; then if [ ! -d /etc/opendkim/keys ]; then
sleep 9999999999999999999 sleep 9999999999999999999
elif [ -z "$(find /etc/opendkim/keys -type d ! -name .)" ]; then elif [ -z "$(find /etc/opendkim/keys -type f ! -name .)" ]; then
sleep 9999999999999999999 sleep 9999999999999999999
else else
/usr/sbin/opendkim -D -f -x /etc/opendkim/opendkim.conf /usr/sbin/opendkim -D -f -x /etc/opendkim/opendkim.conf

4
run.sh
View file

@ -201,7 +201,7 @@ if [ ! -z "$MASQUERADED_DOMAINS" ]; then
fi fi
DKIM_ENABLED= DKIM_ENABLED=
if [ -d /etc/opendkim/keys ] && [ ! -z "$(find /etc/opendkim/keys -type d ! -name .)" ]; then if [ -d /etc/opendkim/keys ] && [ ! -z "$(find /etc/opendkim/keys -type f ! -name .)" ]; then
DKIM_ENABLED=", ${emphasis}opendkim${reset}" DKIM_ENABLED=", ${emphasis}opendkim${reset}"
echo -e "$notice Configuring OpenDKIM." echo -e "$notice Configuring OpenDKIM."
mkdir -p /var/run/opendkim mkdir -p /var/run/opendkim
@ -227,7 +227,7 @@ if [ -d /etc/opendkim/keys ] && [ ! -z "$(find /etc/opendkim/keys -type d ! -nam
echo "" >> /etc/opendkim/TrustedHosts echo "" >> /etc/opendkim/TrustedHosts
if [ ! -z "$ALLOWED_SENDER_DOMAINS" ]; then if [ ! -z "$ALLOWED_SENDER_DOMAINS" ]; then
for i in $ALLOWED_SENDER_DOMAINS; do for i in $ALLOWED_SENDER_DOMAINS; do
private_key=/etc/opendkim/keys/$i/mail.private private_key=/etc/opendkim/keys/$i.private
if [ -f $private_key ]; then if [ -f $private_key ]; then
echo -e " ...for domain ${emphasis}$i${reset}" echo -e " ...for domain ${emphasis}$i${reset}"
echo "*.$i" >> /etc/opendkim/TrustedHosts echo "*.$i" >> /etc/opendkim/TrustedHosts