vmail-stack/bin/vmail-dkim-del.sh
Matthew Saunders Brown 23b2087d07 enable verbose mode
2023-10-10 13:16:57 -07:00

71 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
#
# vmail-stack
# https://git.stack-source.com/msb/vmail-stack
# Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# load include file
source $(dirname $0)/vmail.sh
help()
{
thisfilename=$(basename -- "$0")
echo "$thisfilename"
echo "Remove DKIM key(s) from server for specified domain."
echo ""
echo "usage: $thisfilename -d <domain> [-v] [-h]"
echo ""
echo " -h Print this help."
echo " -d Domain name to remove DKIM keys for."
echo " -v Verbose - output instructions regarding DNS."
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
echo "Domain name is required."
exit 1
fi
# check for existing dkim
if [ ! -f /etc/ssl/dkim/$domain.dkim ]; then
echo "DKIM for $domain does not exist."
exit 1
else
if [[ -f /etc/ssl/dkim/$domain.selector ]]; then
if [[ -n $verbose ]]; then
if [[ -f /usr/local/etc/pdns.conf ]]; then
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
fi
rm /etc/ssl/dkim/$domain.selector
fi
fi
if [ -f /etc/ssl/dkim/$domain.dkim ]; then
rm /etc/ssl/dkim/$domain.dkim
fi
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