home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 400-499 / ff473.lzh / CNewsSrc / cnews_src.lzh / relay / altctl / checkgroups.ne next >
Text File  |  1990-01-11  |  3KB  |  120 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. # v1.4 of 9/4/84, adapted to C news
  6. # added handling of changes in moderated for groups.  Dan
  7.  
  8. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  9. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  10. export NEWSCTL NEWSBIN NEWSARTS
  11. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  12. umask $NEWSUMASK
  13.  
  14. # generate newsgroups from localgroups & stdin
  15. cp $NEWSCTL/localgroups $NEWSCTL/newsgroups
  16. sed '1,/^$/d' >>$NEWSCTL/newsgroups    # behead the article (snuff headers)
  17.  
  18. # generate list of approved newsgroups from $nl/newsgroups
  19. echo junk >/tmp/$$a
  20. echo control >>/tmp/$$a
  21. # [^.]*\. in next two egreps was net.|mod.|fa., which is inadequate - geoff
  22. sed 's/[ \    ].*//' $NEWSCTL/newsgroups |
  23.     egrep "^([^.]*\.|general)" >>/tmp/$$a
  24. sort -u /tmp/$$a -o /tmp/$$a
  25.  
  26. # generate list of locally-present newsgroups from $nl/active
  27. egrep "^([^.]*\.|general|junk|control)" $NEWSCTL/active |
  28.     sed 's/ .*//' | sort  -u >/tmp/$$b
  29.  
  30. comm -13 /tmp/$$a /tmp/$$b >/tmp/$$missing
  31. comm -23 /tmp/$$a /tmp/$$b >/tmp/$$remove
  32.  
  33. egrep "^([^.]*\.|general|junk|control)" $NEWSCTL/active | sed -n "/m\$/s/ .*//p" |
  34.       sort -u > /tmp/$$amod.all
  35. egrep "^([^.]*\.|general)"  $NEWSCTL/newsgroups |
  36. sed -n "/Moderated/s/[     ][     ]*.*//p" | sort -u > /tmp/$$ng.mod
  37.  
  38. comm -12 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.mod
  39. comm -23 /tmp/$$missing /tmp/$$ng.mod >/tmp/$$add.unmod
  40. cat /tmp/$$add.mod /tmp/$$add.unmod >>/tmp/$$add
  41.  
  42. comm -23 /tmp/$$amod.all /tmp/$$remove >/tmp/$$amod
  43. comm -13 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$ismod
  44. comm -23 /tmp/$$ng.mod /tmp/$$amod >/tmp/$$nm.all
  45. comm -23 /tmp/$$nm.all /tmp/$$add >/tmp/$$notmod
  46.  
  47.  
  48. if test -s /tmp/$$remove; then
  49.     echo "The following newsgroups are not valid and should be removed."
  50.     sed "s/^/    /" /tmp/$$remove
  51.     echo ""
  52.     echo "You can do this by executing the command:"
  53.     echo "    $NEWSCTL/ctl/rmgroup.auto \\"
  54.     sed 's;.*;        & \\;' /tmp/$$remove
  55.     echo ""
  56. fi 2>&1 >/tmp/$$out
  57.  
  58. if test -s /tmp/$$add; then
  59.     echo "The following newsgroups were missing." # "and were added."
  60.     sed "s/^/    /" /tmp/$$add
  61.     echo ""
  62.     echo "You can add them by executing the command(s):"
  63.     for i in `cat /tmp/$$add.unmod`
  64.     do
  65.         echo "$NEWSBIN/ctl/newgroup $i </dev/null"
  66.     done
  67.     for i in `cat /tmp/$$add.mod`
  68.     do
  69.         echo "$NEWSBIN/ctl/newgroup $i moderated </dev/null"
  70.     done
  71.     echo ""
  72.  
  73. #    for i in `cat /tmp/$$add`
  74. #    do
  75. # *** "Subject: cmsg " is a hideous botch of a kludge-hack; avoid it!
  76. #        inews -h <<!
  77. #Control: newgroup $i
  78. #Newsgroups: control
  79. #Subject: newgroup $i
  80. #Distribution: general
  81. #
  82. #Create $i locally.
  83. #!
  84. #    done
  85.  
  86. fi 2>&1 >>/tmp/$$out
  87.  
  88. if test -s /tmp/$$ismod;then
  89.     echo "The following newsgroups are not moderated and are marked moderated."
  90.     sed "s/^/    /" /tmp/$$ismod
  91.     echo ""
  92.     echo "You can correct this by executing the command(s):"
  93.     for i in `cat /tmp/$$ismod`
  94.     do
  95.         echo  "$NEWSBIN/ctl/newgroup $i </dev/null"
  96.     done
  97.     echo ""
  98. fi 2>&1 >>/tmp/$$out
  99.  
  100.  
  101. if test -s /tmp/$$notmod; then
  102.     echo "The following newsgroups are moderated and not marked so."
  103.     sed "s/^/    /" /tmp/$$notmod
  104.     echo ""
  105.     echo "You can correct this by executing the command(s):"
  106.     for i in `cat /tmp/$$notmod`
  107.     do
  108.         echo "$NEWSBIN/ctl/newgroup $i moderated </dev/null"
  109.     done
  110.     echo ""
  111. fi 2>&1 >>/tmp/$$out
  112.  
  113.  
  114. if test -s /tmp/$$out; then
  115.     (echo "Subject: Problems with your active file"; echo "";
  116.      cat /tmp/$$out) | mail $NEWSMASTER
  117. fi
  118.  
  119. rm -f /tmp/$$*        # clean up temporaries
  120.