home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d473 / cnewssrc / cnews_src.lzh / relay / ctl / checkgroups next >
Text File  |  1990-01-11  |  2KB  |  79 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. # locate our subscription list
  22. me="`newshostname`"
  23. gngppat=`awk -f $NEWSBIN/relay/canonsys.awk $NEWSCTL/sys |
  24.     egrep "^($me|ME):" |
  25.     awk -F: '
  26. {
  27.     fields = split($2, field2, "/")    # split ngs/dists
  28.     print field2[1]            # print only ngs
  29.     exit
  30. }' `
  31.  
  32. # generate list of approved newsgroups from $nl/newsgroups
  33. (echo junk; echo control; sed 's/[ \    ].*//' $NEWSCTL/newsgroups |
  34.     egrep "^([^.]*\.|general)") | gngp -a "$gngppat" | sort -u >/tmp/$$a
  35.  
  36. # generate list of locally-present newsgroups from $nl/active
  37. egrep "^([^.]*\.|general|junk|control)" $NEWSCTL/active | sed 's/ .*//' |
  38.     sort -u >/tmp/$$b
  39.  
  40. # compare 'em & note differences
  41. comm -13 /tmp/$$a /tmp/$$b >/tmp/$$remove
  42. comm -23 /tmp/$$a /tmp/$$b >/tmp/$$add
  43.  
  44. if test -s /tmp/$$remove; then
  45.     echo "The following newsgroups are not valid and should be removed."
  46.     sed "s/^/    /" /tmp/$$remove
  47.     echo ""
  48.     echo "You can do this by executing the commands:"
  49.     sed "s;.*;     $NEWSBIN/maint/delgroup &;" /tmp/$$remove
  50.     echo ""
  51. fi 2>&1 >/tmp/$$out
  52.  
  53. if test -s /tmp/$$add; then
  54.     echo "The following newsgroups were missing." # "and were added."
  55.     sed "s/^/    /" /tmp/$$add
  56.     echo ""
  57.  
  58. #    for i in `cat /tmp/$$add`
  59. #    do
  60. # *** "Subject: cmsg " is a hideous botch of a kludge-hack; avoid it!
  61. #        inews -h <<!
  62. #Control: newgroup $i
  63. #Newsgroups: control
  64. #Subject: newgroup $i
  65. #Distribution: general
  66. #
  67. #Create $i locally.
  68. #!
  69. #    done
  70.  
  71. fi 2>&1 >>/tmp/$$out
  72.  
  73. if test -s /tmp/$$out; then
  74.     (echo "Subject: Problems with your active file"; echo "";
  75.      cat /tmp/$$out) | mail $NEWSMASTER
  76. fi
  77.  
  78. rm -f /tmp/$$*        # clean up temporaries
  79.