2021-02-10 16:16:23 -08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# vmail-stack
|
|
|
|
# https://git.stack-source.com/msb/vmail-stack
|
|
|
|
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
|
|
|
|
2021-04-02 12:02:50 -07:00
|
|
|
# load include file
|
|
|
|
source $(dirname $0)/vmail.sh
|
2021-02-10 16:16:23 -08:00
|
|
|
|
2021-10-15 15:17:29 -07:00
|
|
|
|
|
|
|
help()
|
|
|
|
{
|
|
|
|
thisfilename=$(basename -- "$0")
|
|
|
|
echo "$thisfilename"
|
2022-07-22 12:47:49 -07:00
|
|
|
echo "Remove DKIM key(s) from server for specified domain."
|
2021-10-15 15:17:29 -07:00
|
|
|
echo ""
|
|
|
|
echo "usage: $thisfilename -d <domain> [-h]"
|
|
|
|
echo ""
|
|
|
|
echo " -h Print this help."
|
2022-07-22 12:47:49 -07:00
|
|
|
echo " -d Domain name to remove DKIM keys for."
|
2021-10-15 15:17:29 -07:00
|
|
|
echo ""
|
|
|
|
echo " DKIM key for the specified domain is removed from the server and"
|
|
|
|
echo " outgoing emails will no longer be signed with DKIM. You should also"
|
|
|
|
echo " remove the associated DNS entry, however leaving the DNS entry in"
|
|
|
|
echo " place should not cause any immediate problems."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
vmail:getoptions "$@"
|
|
|
|
|
|
|
|
# check for domain
|
|
|
|
if [[ -z $domain ]]; then
|
2022-07-22 12:47:49 -07:00
|
|
|
echo "Domain name is required."
|
|
|
|
exit 1
|
2021-02-10 16:16:23 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check for existing dkim
|
2021-10-15 15:17:29 -07:00
|
|
|
if [ ! -f /etc/ssl/dkim/$domain.dkim ]; then
|
2022-07-22 12:47:49 -07:00
|
|
|
echo "DKIM for $domain does not exist."
|
2021-02-10 16:16:23 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-07-22 12:47:49 -07:00
|
|
|
if [[ -f /etc/ssl/dkim/$domain.selector ]]; then
|
|
|
|
echo Deleting the `cat /etc/ssl/dkim/$domain.selector`._domainkey.$domain DKIM key.
|
|
|
|
if [[ -f /usr/local/etc/pdns.conf ]] &&
|
|
|
|
echo To remove the associated DNS record run this command:
|
|
|
|
echo
|
|
|
|
echo pdns-rr-del.sh -z $domain -n `cat /etc/ssl/dkim/$domain.selector`._domainkey.$domain -t TXT
|
|
|
|
else
|
|
|
|
echo You can now delete the DNS TXT record for `cat /etc/ssl/dkim/$domain.selector`._domainkey.$domain
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo You can now delete the associated DNS TXT record.
|
|
|
|
fi
|
2021-02-10 16:16:23 -08:00
|
|
|
|
2022-07-22 12:47:49 -07:00
|
|
|
rm /etc/ssl/dkim/$domain.dkim
|
|
|
|
if [ ! -f /etc/ssl/dkim/$domain.dns ]; then
|
|
|
|
rm /etc/ssl/dkim/$domain.dns
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/ssl/dkim/$domain.pem ]; then
|
|
|
|
rm /etc/ssl/dkim/$domain.pem
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/ssl/dkim/$domain.pub ]; then
|
|
|
|
rm /etc/ssl/dkim/$domain.pub
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/ssl/dkim/$domain.selector ]; then
|
|
|
|
rm /etc/ssl/dkim/$domain.selector
|
|
|
|
fi
|