-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
175 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dkim.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
OUTPUT='/etc/opendkim.conf' | ||
|
||
# exit if config already exists | ||
[ -f "${OUTPUT}" ] && exit 0 | ||
|
||
# defaults | ||
: ${DKIM_KEYFILE:='/etc/opendkim/dkim.key'} | ||
: ${DKIM_DOMAINS:="${MAILNAME}"} | ||
: ${DKIM_SELECTOR:='mail'} | ||
|
||
# Checks | ||
if [ ! -f "${DKIM_KEYFILE}" ]; then | ||
echo "dkim >> Error: DKIM_KEYFILE ${DKIM_KEYFILE} not found" | ||
# shutdown everything | ||
s6-svscanctl -t /etc/s6 | ||
exit 128 | ||
else | ||
echo "dkim >> Setting mode and owner on $DKIM_KEYFILE" | ||
chown opendkim:opendkim ${DKIM_KEYFILE} | ||
chmod 400 ${DKIM_KEYFILE} | ||
fi | ||
|
||
# Status Output | ||
echo "dkim >> Setting DKIM_KEYFILE to $DKIM_KEYFILE" | ||
echo "dkim >> Setting DKIM_DOMAINS to $DKIM_DOMAINS" | ||
echo "dkim >> Setting DKIM_SELECTOR to $DKIM_SELECTOR" | ||
|
||
# Render the dkim config | ||
cat > ${OUTPUT} <<EOF | ||
# This is a basic configuration that can easily be adapted to suit a standard | ||
# installation. For more advanced options, see opendkim.conf(5) and/or | ||
# /usr/share/doc/opendkim/examples/opendkim.conf.sample. | ||
# Log to syslog | ||
Syslog yes | ||
SyslogSuccess yes | ||
# Required to use local socket with MTAs that access the socket as a non- | ||
# privileged user (e.g. Postfix) | ||
UMask 002 | ||
## Create a socket through which your MTA can communicate. | ||
Socket inet:8891@localhost | ||
# Sign for example.com with key in /etc/mail/dkim.key using | ||
# selector '2007' (e.g. 2007._domainkey.example.com) | ||
Domain ${DKIM_DOMAINS} | ||
KeyFile ${DKIM_KEYFILE} | ||
Selector ${DKIM_SELECTOR} | ||
# Commonly-used options; the commented-out versions show the defaults. | ||
Canonicalization relaxed | ||
Mode s | ||
#SubDomains no | ||
#ADSPAction continue | ||
## Specifies whether or not the filter should generate report mail back | ||
## to senders when verification fails and an address for such a purpose | ||
## is provided. See opendkim.conf(5) for details. | ||
SendReports yes | ||
# Always oversign From (sign using actual From and a null From to prevent | ||
# malicious signatures header fields (From and/or others) between the signer | ||
# and the verifier. From is oversigned by default in the Debian pacakge | ||
# because it is often the identity key used by reputation systems and thus | ||
# somewhat security sensitive. | ||
OversignHeaders From | ||
# List domains to use for RFC 6541 DKIM Authorized Third-Party Signatures | ||
# (ATPS) (experimental) | ||
#ATPSDomains example.com | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
echo "FINISH $(pwd) WITH: ${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
[ "$DEBUG" == 'true' ] && set -x | ||
|
||
# Fix issue with dpkg-reconfigure and locales not installed "perl: warning: Setting locale failed." | ||
unset LANG | ||
|
||
cd /etc/s6/opendkim | ||
|
||
# Defaults | ||
: ${USE_DKIM:='no'} | ||
|
||
# Exit if dkim disabled | ||
if [ "${USE_DKIM}" != "yes" ]; then | ||
echo "dkim >> USE_DKIM = ${USE_DKIM}. Not starting opendkim." | ||
s6-svc -d $(pwd) | ||
exit | ||
fi | ||
|
||
# Render config template | ||
/etc/opendkim.conf.sh | ||
|
||
# exit cleanly | ||
trap "{ /usr/sbin/service opendkim stop; }" EXIT | ||
|
||
# start postfix | ||
/usr/sbin/service opendkim start | ||
|
||
sleep 10 # wait for startup | ||
|
||
# watch for opendkim exit | ||
while kill -0 $(pidof opendkim) 2>/dev/null; do | ||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters