Subject: automated UUCP maps Newsgroups: mod.sources Approved: jpn@panda.UUCP Mod.sources: Volume 5, Issue 2 Submitted by: gc@vax135.uucp (Eugene Cristofor) We are taking the maps automatically from the net with the shells attached. It seems to work well - I tought you may want to let other people in this business know about them. gene ------------------------ CUT HERE ------------------------------ # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # README crontab.local uugetmaps uumkmk echo x - README cat > "README" << '//E*O*F README//' The UUCP maps are automatically read from the net by uugetmaps(1L) which is fired by the cron every 6 days. Uugetmaps(1L) strips the news headers from the files and installs them in the public uumap directory. Next, uumkmk(1L) is fired (only if the previous step was ok), which build a makefile on the fly containing the map names and invokes pathalias(1L) to build the UUPATH database. The user interface is the uupath(1L) program that takes input of the form: machine!user and returns the full path from the UUPATH database like: mach1!mach2!...!user //E*O*F README// echo x - crontab.local cat > "crontab.local" << '//E*O*F crontab.local//' /usr/lib/crontab.local:45 1 * * 6 (cd /usr/spool/uucppublic/uumap ; uugetmaps && uumkmk && make) >>/usr/adm/cronlog 2>&1 //E*O*F crontab.local// echo x - uugetmaps cat > "uugetmaps" << '//E*O*F uugetmaps//' #!/bin/sh # @(#)uugetmaps.sh 1.2 # Reads the netnews for the UUCP maps, exctract them and # moves them to the storage area DEST=/usr/spool/uucppublic/uumap ADM=gc NEWSGROUP=mod.map KEYWORDS="UUCP map" TMP=/tmp/uugetmaps.$$ DIR=/usr/tmp/uugetmaps trap "rm -f $TMP ; exit 1" 2 3 15 # Go to an empty directory if [ -d $DIR ] then rm -fr $DIR/* else mkdir $DIR fi cd $DIR || exit 1 # Throw away the headers of the new articles and undo the # maps - assume that they are shar(1L) archives readnews -n $NEWSGROUP -t "${KEYWORDS}" -p | awk ' /^----/ {next;} /^Newsgroup/ {next;} /^Article/ {next;} /^Subject/ {next;} /^From/ {next;} /^Path/ {next;} /^Date/ {next;} /^Sender/ {next;} /^Message/ {next;} /^Expires/ {next;} /^Reply/ {next;} /^Relay/ {next;} /^Posting/ {next;} /^Follow/ {next;} /^Organization/ {next;} /^Newsgroups/ {next;} /^References/ {next;} /^Control/ {next;} {print;}' | sh # Move maps to the storage area - assume that they are named u.* echo "~s UUCP maps" > $TMP echo "The following maps received:" >> $TMP k=0 for i in u.* do if [ -f $DEST/$i ] then mv $DEST/$i $DEST/O$i fi mv $i $DEST echo $DEST/$i >> $TMP k=`expr $k + 1` done if [ k -gt 0 ] then mail $ADM < $TMP fi rm -f $TMP exit 0 # "@{#}@{#}pathalias.sl 1.9 " # @(#)Makefile 1.6 # @(#)uupath.1 1.2 //E*O*F uugetmaps// echo x - uumkmk cat > "uumkmk" << '//E*O*F uumkmk//' #!/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 //E*O*F uumkmk// exit 0