[comp.mail.uucp] automatic map generation

bronson@mfci.UUCP (Tan Bronson) (01/08/88)

    What is the current way to automatically maintain a usenet map ?
A few years ago, I had a version of 'uuhosts' which could unbatch for
System V systems and I hacked it to run pathalias etc when it was
done.
   I'm on a BSD host and I see there is a C version of 'unshar' for the maps,
can someone help me ? Is uuhosts still the best way to get this done ?

many thanks
Tan Bronson
Multiflow Computer Inc  UUCP(work): {yale,uunet}!mfci!bronson 
175 N Main St 		UUCP(home): {yale,mfci}!bronson!tan 
Branford, Ct 06405	Phone(work):(203)-488-6090 x228

rsalz@bbn.com (Rich Salz) (01/12/88)

Tan Bronson, <bronson@mfci.UUCP>, asks for the best way to unpack the maps
and automatically run pathalias afterwards.  Here's the script I use,
called nightly from cron.  You'll need to make changes (hopefully you
don't run MMDF :-), and it's certainly not the "best" way, but it should get
you going.  The heart is the "elif echo" near the beginning.

#! /bin/sh
##  Script to build UUCP maps if the uuhosts Index file has been modified.
##  This script is in three major sections, each with its own config data.

##
##  PROLOG SECTION
##
PATH=/usr/uucp/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin: ; export PATH

##  Capture output.
exec >>/usr/uucp/bin/make-uucp-maps.out 2>&1
cd /usr/ftp/uumap/comp.mail.maps
echo "Started map script on `date`."

##  Ensure the index file exists; if it does, and it's new, make new maps.
uuhosts -unbatch
if [ ! -r Index ] ; then
    echo "Rebuilding uuhosts index file."
    uuhosts -i
elif echo "COSTS PATHS: Index; @/bin/false" | make -qf - ; then
    exec echo "No new map data."
fi


##
##  PATHALIAS SECTION
##
echo "Starting pathalias on `date`."

##  Dead machines and links.
DEAD="-dmirror"

##  Overloaded machines and links.
AVOID="-aihnp4"

##  Debugging.
#TRACE="-tuunet"
DEBUG="-vvv ${TRACE}"

##  The path files.  First read private updates like u.BBN, then read the
##  domain files, then the raw map files.
P1="u.[A-Z]*"
P2="d.*"
P3="u.[a-z]*"
PATHS="${P1} ${P2} ${P3}"

##  Crunch, crunch
pathalias -i -c ${DEBUG} ${DEAD} ${AVOID} ${PATHS} |\
	awk '{ printf "%s\t%s\t%s\n", $2, $1, $3 }' >COSTS
awk '{ printf "%s\t%s\n", $1, $3 }' <COSTS >PATHS
sort +1.0 -n -o COSTS COSTS
sort -f -o PATHS PATHS


##
##  MMDF SECTION
##

##  Who are we working for?
HOST=BBN
echo "Starting MMDF tables on `date`."

##  Write the tables.
awk '{printf "%s.uucp:%s\n", $1, $2;}' <PATHS >${HOST}.chan
awk '{printf "%s:%s.uucp\n", $1, $1;}' <PATHS >${HOST}.domain

for EXT in chan domain ; do
    FILE=${HOST}.${EXT}
    BACKUP=${FILE}.old

    # Safety check.
    if [ ! -s ${FILE} ] ; then
	echo "${FILE} is zero length."
	continue;
    fi

    # Different?
    if cmp -s ${FILE} ${BACKUP} ; then
	echo "${FILE} unchanged"
    else
	echo "New ${FILE}"
	cp ${FILE} ${BACKUP}
	cp ${FILE} /usr/mmdf/table/uucp.${EXT}
    fi
done

echo "Done on `date`."
-- 
For comp.sources.unix stuff, mail to sources@uunet.uu.net.