Path: utzoo!utstat!news-server.csri.toronto.edu!rutgers!ucsd!ucbvax!hplabs!nsc!taux01!amos From: amos@taux01.nsc.com (Amos Shapir) Newsgroups: news.software.b Subject: Re: "de-junking" script Summary: Must be in the Frequently Asked list Message-ID: <4368@taux01.nsc.com> Date: 18 Aug 90 19:58:14 GMT References: <60458@lanl.gov> Organization: National Semiconductor (IC) Ltd, Israel, Home of the Series 32000 Lines: 120 X-Hdate: 28 Av 5750 Since this is a popular request, I decided to post: [Quoted from the referenced article by dhc@lanl.gov (Dave Carter)] > >i need a script to go through my junk directory, and put the "junk" >articles where they belong, and creating the new newsgroup in the >active file if necessary. our active file was missing a bunch of >newsgroups for a long time, and the junk directory has built up quite >a collection > >i seem to remember someone posting something like this, but i was not >interested at the time. o / o / o / o / --Cut-here-------X---------------X---------------X---------------X---- o \ o \ o \ o \ #!/bin/sh # mvjunk.sh # # Move news files out of junk and into their proper directories, # updating the active list and localgroups as we go. # Unknown newsgroups found in junked articles are created by a newgroups # article; the articles are then reposted in case the group is required # across the local net, and to put the group creation into the news logs. # # TRW Advanced Technology Facility STA 2-Jun-1985 # # Modified 10/22/85-James M. Scardelis, SA, Warner Computer Systems # to create newsgroups locally only. # # Modified April 1989 David Wright dww@stl.stc.co.uk # to fix bugs in group creation and make directories include parents # # Modified Aug. 1989 Amos Shapir amos@taux01.nsc.com # to repost found articles rather than mess around with the # active file. # # This program is in the public domain - do with it whatever you like. # # # Actions taken and strange occurences are recorded in mvjunk-log. # Set DISTRIB to cover your local net or organisation if you want any # new groups found to be created across your net. The default is local only # This version is BSD-ish; to convert to sysV-ish systems, change 'hostname' # to 'uname', and 'echo -n xxx' to 'echo xxx\c' . DISTRIB=${DISTRIB-local} INEWS=${INEWS-/usr/lib/news/inews} HOST=${HOST-`hostname`} JUNK=/usr/spool/news/junk SPOOL=/usr/spool/news LIB=/usr/lib/news umask 22 cd $JUNK if /bin/test -z "`ls`" ; then exit fi chmod u+wr * for j in $JUNK/* do for group in `egrep '^Newsgroups:' $j | head -1 | \ sed 's;Newsgroups:[ ];;' | \ sed 's;,; ;g'` do echo "Found article $j for group $group" | tee -a $LIB/mvjunk-log l=`egrep '^Control:' $j` case "$l" in '') : ;; *) group="control";; esac # # Create group if necessary # cd $SPOOL the_date=`date` entry=`egrep "^$group " $LIB/active` case "$entry" in '') echo -n "Create group $group? " read answer case "$answer" in y*) echo \ "Created $the_date to hold articles found in junk"|\ $LIB/inews -d $DISTRIB -C $group echo "Created group $group at $the_date" \ >> $LIB/mvjunk-log echo \ "$group found in junk; created at $the_date" \ >> $LIB/localgroups ;; *) continue;; esac;; esac # # repost article # sed -e "/^Path:/s/$HOST!//" -e '/^Message-ID:/s//Old-&/' \ -e '/^Distribution:/d' -e '/^Lines:/{' \ -e h -e "s/.*/Distribution: $DISTRIB/" -e G -e \} $j \ | $LIB/inews -h done /bin/rm -i $j # But my MOTHER lives in Hackensack! done o / o / o / o / --Cut-here-------X---------------X---------------X---------------X---- o \ o \ o \ o \ May the Source be with you, always... -- Amos Shapir amos@taux01.nsc.com, amos@nsc.nsc.com National Semiconductor (Israel) P.O.B. 3007, Herzlia 46104, Israel Tel. +972 52 522408 TWX: 33691, fax: +972-52-558322 GEO: 34 48 E / 32 10 N