#!/bin/sh
#	@(#)uumkmk.sh	1.2
#
#	Generates a makefile that will rebuild the UUPATH database from the
#	individual UUPC maps - the assumption is that the maps are deposited
#	by magic into the right directory.
#
#	The makefile is built on the fly because the names of individual
#	maps are not a priori known - the only assumption made is that
#	they are called u.*
#


MASTER=vax135
DIR=/usr/spool/uucppublic/uumap
TMP=/tmp/uumkmap.$$
MK=Makefile

trap	"rm -f $TMP ; exit 1"	2 3 15


if [ `hostname` != $MASTER ]
	then	echo "$0: must be run on $MASTER" >&2; exit 2
fi

# Assumes that maps are called u.*
cd $DIR || exit 3
ls u.* | awk '{printf "\t\t%s\\\n", $0;}' > $TMP

if [ ! -s $TMP ]
	then	echo "$0: no UUCP maps in $DIR" >&2; exit 4
fi

if [ ! -f JUNK ]
	then	cp /dev/null JUNK
fi

# Generate a makefile with the maps as dependents
(
	echo "# This makefile is generated by $0"
	echo "# *** DO NOT REMOVE ***"
	echo "ADM = gc"
	echo
	echo "UUPATH:\\" 
	cat $TMP 
	echo "		JUNK" 
	echo "	mv UUPATH OUUPATH"
	echo "	pathalias -p -l $MASTER\\" 
	cat $TMP 
	echo "		>UUPATH 2>ERR" 
	echo "	echo UUPATH rebuilt | mail $(ADM)"
) > $MK

rm -f $TMP
exit 0
#	"@{#}@{#}pathalias.sl	1.9               "
#	@(#)Makefile	1.6
#	@(#)uupath.1	1.2
