home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume05 / getmaps < prev    next >
Encoding:
Text File  |  1988-09-11  |  4.2 KB  |  186 lines

  1. Subject: automated UUCP maps
  2. Newsgroups: mod.sources
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 5, Issue 2
  6. Submitted by: gc@vax135.uucp (Eugene Cristofor)
  7.  
  8. We are taking the maps automatically from the net with the shells attached.
  9. It seems to work well - I tought you may want to let other people in this
  10. business know about them.
  11.  
  12. gene
  13.  
  14. ------------------------ CUT HERE ------------------------------
  15.  
  16. # This is a shell archive.  Remove anything before this line, then
  17. # unpack it by saving it in a file and typing "sh file".  (Files
  18. # unpacked will be owned by you and have default permissions.)
  19. #
  20. # This archive contains:
  21. # README crontab.local uugetmaps uumkmk
  22.  
  23. echo x - README
  24. cat > "README" << '//E*O*F README//'
  25. The UUCP maps are automatically read from the net by uugetmaps(1L)
  26. which is fired by the cron every 6 days.
  27. Uugetmaps(1L) strips the news headers from the files and installs them
  28. in the public uumap directory.
  29.  
  30. Next, uumkmk(1L) is fired (only if the previous step was ok), which
  31. build a makefile on the fly containing the map names and invokes
  32. pathalias(1L) to build the UUPATH database.
  33.  
  34. The user interface is the uupath(1L) program that takes input of the
  35. form:
  36.     machine!user
  37. and returns the full path from the UUPATH database like:
  38.     mach1!mach2!...!user
  39. //E*O*F README//
  40.  
  41. echo x - crontab.local
  42. cat > "crontab.local" << '//E*O*F crontab.local//'
  43. /usr/lib/crontab.local:45 1 * * 6    (cd /usr/spool/uucppublic/uumap ; uugetmaps && uumkmk && make) >>/usr/adm/cronlog 2>&1
  44. //E*O*F crontab.local//
  45.  
  46. echo x - uugetmaps
  47. cat > "uugetmaps" << '//E*O*F uugetmaps//'
  48. #!/bin/sh
  49. #    @(#)uugetmaps.sh    1.2
  50.  
  51. #    Reads the netnews for the UUCP maps, exctract them and
  52. #    moves them to the storage area
  53.  
  54. DEST=/usr/spool/uucppublic/uumap
  55. ADM=gc
  56. NEWSGROUP=mod.map
  57. KEYWORDS="UUCP map"
  58. TMP=/tmp/uugetmaps.$$
  59. DIR=/usr/tmp/uugetmaps
  60.  
  61.  
  62. trap    "rm -f $TMP ; exit 1"    2 3 15
  63.  
  64. #    Go to an empty directory
  65. if [ -d $DIR ]
  66.     then    rm -fr $DIR/*
  67.     else    mkdir $DIR
  68. fi
  69. cd $DIR || exit 1
  70.  
  71. #    Throw away the headers of the new articles and undo the
  72. #    maps - assume that they are shar(1L) archives
  73. readnews -n $NEWSGROUP -t "${KEYWORDS}" -p |
  74.     awk '
  75.         /^----/            {next;}
  76.         /^Newsgroup/        {next;}
  77.         /^Article/        {next;}
  78.         /^Subject/        {next;}
  79.         /^From/            {next;}
  80.         /^Path/            {next;}
  81.         /^Date/            {next;}
  82.         /^Sender/        {next;}
  83.         /^Message/        {next;}
  84.         /^Expires/        {next;}
  85.         /^Reply/        {next;}
  86.         /^Relay/        {next;}
  87.         /^Posting/        {next;}
  88.         /^Follow/        {next;}
  89.         /^Organization/        {next;}
  90.         /^Newsgroups/        {next;}
  91.         /^References/        {next;}
  92.         /^Control/        {next;}
  93.                     {print;}' |
  94.     sh
  95.  
  96. #    Move maps to the storage area - assume that they are named u.*
  97. echo "~s UUCP maps" > $TMP
  98. echo "The following maps received:" >> $TMP
  99.  
  100. k=0
  101. for i in u.*
  102. do
  103.     if [ -f $DEST/$i ]
  104.         then    mv $DEST/$i $DEST/O$i
  105.     fi
  106.     mv $i $DEST
  107.     echo $DEST/$i >> $TMP
  108.     k=`expr $k + 1`
  109. done
  110.  
  111. if [ k -gt 0 ]
  112.     then    mail $ADM < $TMP
  113. fi
  114. rm -f $TMP
  115. exit 0
  116. #    "@{#}@{#}pathalias.sl    1.9               "
  117. #    @(#)Makefile    1.6
  118. #    @(#)uupath.1    1.2
  119. //E*O*F uugetmaps//
  120.  
  121. echo x - uumkmk
  122. cat > "uumkmk" << '//E*O*F uumkmk//'
  123. #!/bin/sh
  124. #    @(#)uumkmk.sh    1.2
  125. #
  126. #    Generates a makefile that will rebuild the UUPATH database from the
  127. #    individual UUPC maps - the assumption is that the maps are deposited
  128. #    by magic into the right directory.
  129. #
  130. #    The makefile is built on the fly because the names of individual
  131. #    maps are not a priori known - the only assumption made is that
  132. #    they are called u.*
  133. #
  134.  
  135.  
  136. MASTER=vax135
  137. DIR=/usr/spool/uucppublic/uumap
  138. TMP=/tmp/uumkmap.$$
  139. MK=Makefile
  140.  
  141. trap    "rm -f $TMP ; exit 1"    2 3 15
  142.  
  143.  
  144. if [ `hostname` != $MASTER ]
  145.     then    echo "$0: must be run on $MASTER" >&2; exit 2
  146. fi
  147.  
  148. # Assumes that maps are called u.*
  149. cd $DIR || exit 3
  150. ls u.* | awk '{printf "\t\t%s\\\n", $0;}' > $TMP
  151.  
  152. if [ ! -s $TMP ]
  153.     then    echo "$0: no UUCP maps in $DIR" >&2; exit 4
  154. fi
  155.  
  156. if [ ! -f JUNK ]
  157.     then    cp /dev/null JUNK
  158. fi
  159.  
  160. # Generate a makefile with the maps as dependents
  161. (
  162.     echo "# This makefile is generated by $0"
  163.     echo "# *** DO NOT REMOVE ***"
  164.     echo "ADM = gc"
  165.     echo
  166.     echo "UUPATH:\\" 
  167.     cat $TMP 
  168.     echo "        JUNK" 
  169.     echo "    mv UUPATH OUUPATH"
  170.     echo "    pathalias -p -l $MASTER\\" 
  171.     cat $TMP 
  172.     echo "        >UUPATH 2>ERR" 
  173.     echo "    echo UUPATH rebuilt | mail $(ADM)"
  174. ) > $MK
  175.  
  176. rm -f $TMP
  177. exit 0
  178. #    "@{#}@{#}pathalias.sl    1.9               "
  179. #    @(#)Makefile    1.6
  180. #    @(#)uupath.1    1.2
  181. //E*O*F uumkmk//
  182.  
  183. exit 0
  184.  
  185.  
  186.