Added OpenDKIM to Postfix module
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
|
||||
systemctl stop postfix opendkim
|
||||
|
||||
|
||||
##-------------##
|
||||
# Postfix #
|
||||
##-------------##
|
||||
|
||||
sed -i 's/#inet_interfaces = all/inet_interfaces = loopback-only/g' /etc/postfix/main.cf
|
||||
sed -i 's/mydestination/#mydestination/g' /etc/postfix/main.cf
|
||||
sed -i 's/relayhost =/mydestination = '$hostname', localhost.'$hostname', '$hostname'/g' /etc/postfix/main.cf
|
||||
sed -i "/^inet_interfaces =/c\inet_interfaces = loopback-only" /etc/postfix/main.cf
|
||||
sed -i "/recipient_delimiter =/c\recipient_delimiter = +" /etc/postfix/main.cf
|
||||
sed -i "/^mydestination =/c\mydestination = \"$hostname\", localhost.\"$hostname\", \"$hostname\"" /etc/postfix/main.cf
|
||||
echo "$hostname" > /etc/mailname
|
||||
echo "bounce_notice_recipient = info@$domain" >> /etc/postfix/main.cf
|
||||
cat <<EOF > /etc/aliases
|
||||
# See man 5 aliases for format
|
||||
@@ -13,6 +18,50 @@ root: $email
|
||||
EOF
|
||||
newaliases
|
||||
|
||||
systemctl start postfix
|
||||
systemctl enable postfix
|
||||
systemctl reload postfix
|
||||
cat <<EOF >>
|
||||
milter_default_action = accept
|
||||
milter_protocol = 2
|
||||
smtpd_milters = unix:/var/run/opendkim/opendkim.sock
|
||||
non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock
|
||||
EOF
|
||||
|
||||
|
||||
##--------------##
|
||||
# OpenDKIM #
|
||||
##--------------##
|
||||
|
||||
adduser postfix opendkim
|
||||
mkdir /etc/opendkim/keys
|
||||
chown opendkim:opendkim /etc/opendkim/keys -R
|
||||
curl --retry 7 --retry-delay 5 -s "$repo"/raw/"$branchtype"/"$branch"/SubModules/postfix/config/opendkim.conf -o /etc/opendkim.conf
|
||||
cat <<EOF > /etc/opendkim/TrustedHosts
|
||||
127.0.0.1
|
||||
::1
|
||||
localhost
|
||||
$(curl -s -4 icanhazip.com)
|
||||
$(curl -s -6 icanhazip.com)
|
||||
${hostname}
|
||||
EOF
|
||||
|
||||
|
||||
if [ "$shortdist" = "ubu1804" ] || [ "$shortdist" = "ubu2004" ] || [ "$shortdist" = "deb10" ] ; then
|
||||
mkdir /var/spool/postfix/opendkim
|
||||
sudo chown opendkim:postfix /var/spool/postfix/opendkim
|
||||
sed -i "/^RUNDIR=/c\RUNDIR=/var/spool/postfix/var/run/opendkim" /etc/default/opendkim
|
||||
echo "TrustAnchorFile /usr/share/dns/root.key" >> /etc/opendkim/conf
|
||||
bash /lib/opendkim/opendkim.service.generate
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
cat << EOF > /etc/update-motd.d/51-generalSPF
|
||||
#!/bin/sh
|
||||
red='\e[1;31m%s\e[0m\n'
|
||||
printf "\n"
|
||||
printf \$red "To enable mail for this server add \"ip4:\$(curl -s -4 icanhazip.com) ip6:\$(curl -s -6 icanhazip.com)\" to $hostname SPF"
|
||||
printf \$red "remove notice this by running \"rm /etc/update-motd.d/51-generalSPF\""
|
||||
printf "\n"
|
||||
EOF
|
||||
chmod +x /etc/update-motd.d/51-generalSPF
|
||||
|
||||
systemctl start postfix opendkim
|
||||
systemctl enable postfix opendkim
|
||||
|
||||
Reference in New Issue
Block a user