7 if [ ! "$(id -u)" -eq "0" ]; then
8 echo "Must be run as root."
12 apt-get -y install opendkim
14 if [ ! -n "$file" ] || [ ! -f "$file" ]; then
15 apt-get -y install opendkim-tools
16 opendkim-genkey -d plomlompom.com -s $selector
17 apt-get -y --purge autoremove opendkim-tools
20 echo 'Generated key file at '$selector'.private.'
21 echo 'APPLY the content of '$selector'.txt below to your DNS record.'
22 echo 'AFTER the waiting time for DNS propagation RERUN this script with' \
23 'the key file as SECOND parameter (still use selector as first one).'
27 cp ~/config/systemfiles/opendkim.conf /etc/opendkim.conf
28 sed -r -i 's/^#Selector .*$/Selector '$selector'/' /etc/opendkim.conf
29 mkdir -p /etc/opendkim
30 if [ -f /etc/opendkim/dkim.key ]; then
31 cp /etc/opendkim/dkim.key /etc/opendkim/dkim.key~
33 cp $file /etc/opendkim/dkim.key
34 cp ~/config/systemfiles/main.cf /etc/postfix/main.cf
35 cat >> /etc/postfix/main.cf << EOF
37 # Use opendkim at given port as mail filter.
38 non_smtpd_milters = inet:localhost:12301
40 service opendkim restart
41 service postfix restart
44 echo 'Ensure the DKIM TXT entry in your DNS record matches!'