:
# NAME:
#	upddns - cron job for DNS maint
#
# DESCRIPTION:
#	Run from cron(8), this job ensures that the DNS data is up to
#	date.   If 'scm-update' shows any changes made we run 'make
#	depend'.  In any case we run 'make' to ensure that '.soa'
#	files are up to date.
#
# AUTHOR:
#	Simon J. Gerraty <sjg@crufty.net>

# RCSid:
#	$Id: upddns,v 1.16 2023/06/11 18:35:13 sjg Exp $
#
#	@(#)Copyright (c) 1994-2001 Simon J. Gerraty.
#	All rights reserved.
#	
#	This software is the property of Simon J. Gerraty.
#	It may be used only in accordance with the conditions outlined
#	in the accompanying LICENSE file. If your distribution does
#	not contain a LICENSE file, then you have no rights to use
#	this software and should contact sales@crufty.net to obtain a
#	licensed distribution.
#	
#	This software is provided "AS IS" in the hope that it will be
#	of use.  Since it is not possible to anticipate all possible
#	use of this software, there is absolutely NO WARRANTY.
#
#	Please forward bug reports and fixes to help@crufty.net
#

# a dance to find RC_D
Mydir=`dirname $0`
for d in $RC_D $Mydir $Mydir/../etc/rc_d /etc/rc_d
do
	test -s $d/dnsfuncs.sh || continue
	RC_D=`cd $d && 'pwd'`; export RC_D
	. $d/dnsfuncs.sh
	break
done

# by now we should be in $DNSDIR
MAKE=${MAKE:-make}
test -s .dnsmagicrc && . ./.dnsmagicrc
# XXX this make command assumes bmake
DNSMAGIC=${DNSMAGIC:-`${MAKE} -C $DNSDIR -V '${DNSMAGIC}'`}
SCM_UPDATE=${SCM_UPDATE:-$DNSMAGIC/bin/scm-update.sh}

if $SCM_UPDATE; then
	cat .scm.update
	# make sure dependencies are up to date
	$MAKE depend
fi
# now run make to ensure all is ok
$MAKE CVS_UPDATE=@: SCM_UPDATE=@:
# and again incase that did a make depend...
$MAKE CVS_UPDATE=@: SCM_UPDATE=@:
# Ok, see if we have to ship anything to our secondaries
# you can use anything - rdist, rsync, SSLrdist,
# so long as it does not need human interaction.
test -s .rdistrc && . ./.rdistrc

