Path: utzoo!utgpu!water!watmath!clyde!ima!bbn!bbn.com!rsalz From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.mail.uucp Subject: Re: automatic map generation Message-ID: <290@fig.bbn.com> Date: 11 Jan 88 16:27:07 GMT References: <206@m2.mfci.UUCP> Organization: BBN Laboratories, Cambridge MA Lines: 95 Tan Bronson, , 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 }' 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;}' ${HOST}.chan awk '{printf "%s:%s.uucp\n", $1, $1;}' ${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.