home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / auucp+-1.02 / fuucp_plus_src.lzh / unsharmap / map.daily < prev    next >
Encoding:
Text File  |  1990-11-21  |  2.2 KB  |  75 lines

  1. :
  2. # ------------------------------------------------------------------
  3. #  Title    : map.daily -- automatically install new maps
  4. #  Usage    : map.daily [ -v ] [ -V ]
  5. #  Options    :     -v : Verbose mode, show up "no op" invocation
  6. #            -V : Very Verbose Mode
  7. #  Version      :       Sat, 26-May-90 / 11:45 / (root@artcom0)
  8. #  Remarks    : You may create a directory /usr/lib/uucp/oldmaps
  9. #              with some numerical named subdirectories. e.g.
  10. #          /usr/lib/uucp/oldmaps/0
  11. #              /usr/lib/uucp/oldmaps/1 ...
  12. #          Older maps will be preserved there. 
  13. #              These directories should be owned by 'news' and
  14. #          should also have write-Permissions, if You don't
  15. #          want to run this script here under 'root' !
  16. #          If you don't trust new maps, You may also choose
  17. #          the '-V' option, and You will get a diff mail,
  18. #          whenever there are new maps arrived !
  19. # ------------------------------------------------------------------
  20. if [ "$1" = "-v" ]
  21. then VERBOSE=TRUE
  22.      shift
  23. else VERBOSE=
  24. fi
  25. if [ "$1" = "-V" ]
  26. then VERBOSE=Talkative
  27.      shift
  28. fi
  29. MAPDIR=/usr/lib/uucp/maps
  30. OLDMAPS=/usr/lib/uucp/oldmaps
  31. cd $MAPDIR/work
  32. # --- Do the installation
  33. NEWMAPS=
  34. for i in * ; do
  35.     if [ "$i" = "*" ]
  36.     then if [ "$VERBOSE" ]
  37.      then echo "No new maps arrived !"  
  38.      fi 
  39.      exit 0
  40.     fi
  41.     # -- preserve old maps 
  42.     for olddirnum in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ; do
  43.     OLDMAPDIR=$OLDMAPS/$olddirnum
  44.     if [ -d $OLDMAPDIR ]
  45.     then if [ $olddirnum -gt 0 ]
  46.          then prevdirnum=`expr $olddirnum - 1`
  47.           PREVDIR=$OLDMAPS/$prevdirnum
  48.          else PREVDIR=$MAPDIR
  49.          fi
  50.          if [ -f $PREVDIR/$i ]
  51.          then mv $PREVDIR/$i $OLDMAPDIR/$i
  52.          fi
  53.     fi
  54.     done
  55.     mv $i $MAPDIR
  56.     NEWMAPS="$NEWMAPS $i"
  57. done
  58. # -- mail significant map changes as diff to the postmaster :
  59. if [ "$VERBOSE" = "Talkative" ] && [ -d $OLDMAPS/0 ]
  60. then if [ -x /usr/local/bin/gdiff ]
  61.      then /usr/local/bin/gdiff -r -c $OLDMAPS/0 $MAPDIR
  62.      else cd $MAPDIR
  63.       for i in $NEWMAPS ; do
  64.           if [ -r $OLDMAPS/0/$i ]
  65.           then echo "--- $i Differences: ---"
  66.            diff $OLDMAPS/0/$i $i
  67.           else echo "--- $i is a new map file ! ---"
  68.           fi
  69.       done
  70.      fi | mail -s "Map Changes" postmaster
  71. fi
  72. # -- regenerate the paths database :
  73. cd $MAPDIR
  74. ./mkpaths
  75.