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 / relay / ctl / checkgroups next >
Text File  |  1989-06-27  |  2KB  |  70 lines

  1. #! /bin/sh
  2. # checkgroups - check active file for missing or extra newsgroups.
  3. #    stdin must a checkgroups news article, sends mail to $NEWSMASTER
  4. #    after updating $nl/newsgroups from $nl/localgroups
  5. # based on v1.4 of 9/4/84
  6.  
  7. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  8. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  9. export NEWSCTL NEWSBIN NEWSARTS
  10. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  11. umask $NEWSUMASK
  12.  
  13. # generate newsgroups from localgroups & beheaded stdin (checkgroups article).
  14. # appending to newsgroups instead of overwriting is a hack,
  15. # but is about the best we can do until checkgroups is defined.
  16. (cat $NEWSCTL/localgroups; sed '1,/^$/d') >>$NEWSCTL/newsgroups
  17. # backup newsgroups, then strip duplicates
  18. cp $NEWSCTL/newsgroups $NEWSCTL/newsgroups.bac || exit 1
  19. sort -u -o $NEWSCTL/newsgroups $NEWSCTL/newsgroups.bac
  20.  
  21. # generate list of approved newsgroups from $nl/newsgroups
  22. # [^.]*\. in next two egreps was net.|mod.|fa., which is inadequate - geoff
  23. (echo junk; echo control; sed 's/[ \    ].*//' $NEWSCTL/newsgroups |
  24.     egrep "^([^.]*\.|general)") | sort -u >/tmp/$$a
  25.  
  26. # generate list of locally-present newsgroups from $nl/active
  27. egrep "^([^.]*\.|general|junk|control)" $NEWSCTL/active | sed 's/ .*//' |
  28.     sort -u >/tmp/$$b
  29.  
  30. # compare 'em & note differences
  31. comm -13 /tmp/$$a /tmp/$$b >/tmp/$$remove
  32. comm -23 /tmp/$$a /tmp/$$b >/tmp/$$add
  33.  
  34. if test -s /tmp/$$remove; then
  35.     echo "The following newsgroups are not valid and should be removed."
  36.     sed "s/^/    /" /tmp/$$remove
  37.     echo ""
  38.     echo "You can do this by executing the command:"
  39.     echo "    $NEWSBIN/maint/rmgroup \\"
  40.     sed 's;.*;        & \\;' /tmp/$$remove
  41.     echo ""
  42. fi 2>&1 >/tmp/$$out
  43.  
  44. if test -s /tmp/$$add; then
  45.     echo "The following newsgroups were missing." # "and were added."
  46.     sed "s/^/    /" /tmp/$$add
  47.     echo ""
  48.  
  49. #    for i in `cat /tmp/$$add`
  50. #    do
  51. # *** "Subject: cmsg " is a hideous botch of a kludge-hack; avoid it!
  52. #        inews -h <<!
  53. #Control: newgroup $i
  54. #Newsgroups: control
  55. #Subject: newgroup $i
  56. #Distribution: general
  57. #
  58. #Create $i locally.
  59. #!
  60. #    done
  61.  
  62. fi 2>&1 >>/tmp/$$out
  63.  
  64. if test -s /tmp/$$out; then
  65.     (echo "Subject: Problems with your active file"; echo "";
  66.      cat /tmp/$$out) | mail $NEWSMASTER
  67. fi
  68.  
  69. rm -f /tmp/$$*        # clean up temporaries
  70.