home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff319.lzh / CNewsSrc / cnews.orig.lzh / expire / mkhistory < prev    next >
Text File  |  1989-06-27  |  983b  |  40 lines

  1. #! /bin/sh
  2. # mkhistory - rebuild history file and friends
  3.  
  4. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  5. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  6.  
  7. PATH=$NEWSCTL/bin:$NEWSBIN/expire:$NEWSBIN:$NEWSPATH ; export PATH
  8. umask $NEWSUMASK
  9.  
  10. lock="$NEWSCTL/LOCK"        # modify name as appropriate
  11. ltemp="$NEWSCTL/L.$$"
  12. echo $$ >$ltemp
  13. trap "rm -f $ltemp ; exit 0" 0 1 2 15
  14. while true
  15. do
  16.     if newslock $ltemp $lock
  17.     then
  18.         trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
  19.         break
  20.     fi
  21.     sleep 30
  22. done
  23.  
  24. cd $NEWSARTS
  25. find `ls | egrep -v '\.'` -type f -name '[0-9]*' -print | histinfo | sort |
  26.     awk -f $NEWSBIN/expire/histdups | histslash >$NEWSCTL/history.n
  27.  
  28. cd $NEWSCTL
  29. if egrep '^<swill@trash>    ' history.n >/dev/null
  30. then
  31.     echo "$0: <swill@trash> found in history.n -- aborting" >&2
  32.     exit 1
  33. fi
  34. mkdbm <history.n
  35. mv history history.o &&        # install new ASCII history file
  36. mv history.n history &&
  37. rm -f history.pag &&        # and related dbm files
  38. rm -f history.dir &&
  39. mv hist.pag history.pag && mv hist.dir history.dir
  40.