home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d473 / cnewssrc / cnews_src.lzh / misc / addmissing < prev    next >
Text File  |  1990-12-22  |  1KB  |  57 lines

  1. #! /bin/sh
  2. # addmissing - add missing articles to history
  3. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  4. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  5.  
  6. PATH=$NEWSCTL/bin:$NEWSBIN/expire:$NEWSBIN:$NEWSPATH ; export PATH
  7. umask $NEWSUMASK
  8.  
  9. lock="$NEWSCTL/LOCK"
  10. ltemp="$NEWSCTL/L.$$"
  11. echo $$ >$ltemp
  12. trap "rm -f $ltemp ; exit 0" 0 1 2 15
  13. while true
  14. do
  15.     if newslock $ltemp $lock
  16.     then
  17.         trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
  18.         break
  19.     fi
  20.     sleep 30
  21. done
  22. if newslock $ltemp $NEWSCTL/LOCKexpire
  23. then
  24.     trap "rm -f $ltemp $lock $NEWSCTL/LOCKexpire ; exit 0" 0 1 2 15
  25. else
  26.     echo "$0: expire is running, $0 aborted" >&2
  27.     exit 1
  28. fi
  29.  
  30. cd $NEWSCTL
  31. size="`sizeof history history.pag history.dir`"
  32. if test " `spacefor $size control`" -le 0
  33. then
  34.     echo "$0: not enough space for temporaries, $0 aborted" >&2
  35.     exit 1
  36. fi
  37.  
  38. egrep '    .*    ' history | sed 's/.*    //' | tr '. ' '/
  39. ' | egrep '/' | sort -u >/tmp/hist$$
  40.  
  41. cd $NEWSARTS
  42. find `ls | egrep -v '\.'` -type f -name '[0-9]*' -print | sort >/tmp/tree$$
  43.  
  44. comm -13 /tmp/hist$$ /tmp/tree$$ | histinfo | sort |
  45.     awk -f $NEWSBIN/expire/histdups | histslash >/tmp/new$$
  46.  
  47. cd $NEWSCTL
  48. if egrep '^<[^>]*@trash>    ' /tmp/new$$ >/dev/null
  49. then
  50.     echo "$0: (warning) empty/trash articles found, will expire at once" >&2
  51.     echo "$0:     (grep history file for '@trash' to see them)" >&2
  52. fi
  53.  
  54. dbz -a history /tmp/new$$
  55.  
  56. rm -f /tmp/hist$$ /tmp/tree$$ /tmp/new$$
  57.