home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2768 < prev    next >
Encoding:
Internet Message Format  |  1991-02-17  |  2.4 KB

  1. From: nik@st_nik!swindon.ingr.com (Nik Simpson x4333)
  2. Newsgroups: alt.sources
  3. Subject: Re: Newjunk: scanning the junk directory for new groups
  4. Message-ID: <1991Feb16.142137.22726@st_nik!swindon.ingr.com>
  5. Date: 16 Feb 91 14:21:37 GMT
  6.  
  7.  
  8.     Funny how people do the same thing in different ways,  I'm lazy, I 
  9. wrote my checkjunk as script.  It checks each article in the junk directory
  10. for Newsgroup lines and Approved lines.  New newsgroups that have an Approved
  11. line are created moderated.  Only thos groups in the hierarchies given in the
  12. "ok" variable are created.  This is written for CNEWS,  but the changes for
  13. BNEWS should be minimal.  On the nodes I administer this script runs every night
  14. and the output generated is part of the daily report.
  15.  
  16. -----------------------------------cut here--------------------------------
  17.  
  18. #    This script checks the Newsgroups lines in the articles in the junk
  19. # directory,  if the newgroup  is not in active,  a local newgroup message
  20. # is created.  If the article contains an approved line then we assume that
  21. # the newsgroup should be created moderated,  otherwise it will be unmoderated.
  22. #
  23. ok="comp sci talk misc rec ingr ingreur ingruk general comp control eunet soc
  24. vmsnet gnu unix-pc alt"
  25. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  26. PATH=$PATH:${NEWSCTL}/bin/maint
  27. cd ${NEWSARTS}/junk
  28. USER=checkjunk
  29. export USER
  30. ls * >/dev/null 2>&1
  31. if [ $? -ne 0 ]
  32. then
  33.     echo "No file in junk directory"
  34.     exit 0
  35. fi
  36. for file in *
  37. do
  38.     grep  "^Newsgroups:" $file|sort|uniq|cut -f2 -d":"|sed "s/,.*//g"|
  39.     while read line
  40.     do
  41.         grep "$line" ${NEWSCTL}/active>/dev/null
  42.         if [ $? -ne 0 ]
  43.         then
  44.             grep "^Approved:" $file >/dev/null 2>&1
  45.             if [ $? -eq 0 ]
  46.             then
  47.                 flags=m
  48.                 message="Moderated"
  49.             else
  50.                 flags=y
  51.                 message="Unmoderated"
  52.             fi
  53.             grp=`echo $line|sed "s/\..*//g"`
  54.             OK=1
  55.             set "" $ok
  56.             while [ $OK  -eq 1 ]
  57.             do
  58.                 if [ "$1" = "$grp" ]
  59.                 then
  60.                     OK=0
  61.                 else
  62.                     shift
  63.                     if [ "$1" = "" ]
  64.                     then
  65.                         break
  66.                     fi
  67.                 fi
  68.             done
  69.             if [ $OK -eq 0 ]
  70.             then
  71.                 echo adding $line $message
  72.                 addgroup $line $flags </dev/null
  73.             else
  74.                 echo "Will not add $line"
  75.             fi
  76.         else
  77.             echo "$line ok"
  78.         fi
  79.     done
  80. done |sort|uniq
  81. -------------------------------------------------------------------------------
  82. -- 
  83. |--------------------------------------------------|
  84. |  Nik Simpson    UUCP :uunet!ingr!swindon!st_nik!nik|
  85. |  Systems Consultant (UNIX).   Intergraph UK Ltd. |
  86. |--------------------------------------------------|
  87.