:
# NAME:
#	chkwildmx - check wild card MX records
#
# DESCRIPTION:
#	Run after getdb, checks that there are wildcard MX records for
#	the domains listed in WILD_MX.
#	
# AUTHOR:
#	Simon J. Gerraty <sjg@crufty.net>

# RCSid:
#	$Id: chkwildmx,v 1.8 2022/10/10 00:44:51 sjg Exp $
#
#	@(#) Copyright (c) 1997-2022 Simon J. Gerraty.
#
#	This file is provided in the hope that it will
#	be of use.  There is absolutely NO WARRANTY.
#	Permission to copy, redistribute or otherwise
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	Please send copies of changes and bug-fixes to:
#	sjg@crufty.net
#

Myname=chkwildmx
Mydir=${Mydir:-`dirname $0`}
PATH=$Mydir:$PATH
. debug.sh

DebugOn

[ "$NO_NAMED" ] && exit 0

x=0
ND_DATA=${ND_DATA:-/dev/null}
if [ -s $ND_DATA ]; then
	# not there is no default
	for d in $WILD_MX
	do
		w=`grep "MX \*.$d " $ND_DATA`
		# ok, we are guessing where the MX should be...
		case "$w" in
		"")	echo "hosts/$d.db: missing wildcard MX for '$d'" >&2; x=1;;
		esac
	done
else
	echo "$Myname: no data in $ND_DATA, has getdb run?" >&2
	x=1
fi
exit $x

