🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #746

Re: Local parsing of junk into news groups.

#746
From: Jonathan Bayer
Date: Tue, 24 Jul 1990 11:31
212 lines
7445 bytes
salem@ace.sri.com (Bruce Salem) writes:

>I am using/administrating nn with nntp to a local machine. That
>machine does not recognize certian alt.* groups and so the messages
>all go into the junk newsgroup. Is there any way I can reconstruct
>the alt.* groups from the header info in the junk messages so that
>I can create them without having my server recognize them? Is there
>anyway I can post to these groups, then, even though my server
>doesn't recognize them?


I had the same type of problem, and it was solved by a posting to the net.

I have enclosed it below.  Read the comments carefully as they are the only
documentation around.  Run it once a day (or more often) from cron to solve
your problem.


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  mvjunk
# Wrapped by root@ispi on Tue Jul 24 07:30:00 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'mvjunk' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mvjunk'\"
else
echo shar: Extracting \"'mvjunk'\" \(4680 characters\)
sed "s/^X//" >'mvjunk' <<'END_OF_FILE'
X#!/bin/sh
X# mvjunk.sh
X#
X# Move news files out of junk and into their proper directories,
X# updating the active list and localgroups as we go.
X# Unknown newsgroups found in junked articles are created by adding an
X# entry to the active file and creating the directory.    A newgroups
X# article is also posted in case the group is required across the local net,
X# and to put the group creation into the news logs.
X#
X# TRW Advanced Technology Facility  STA 2-Jun-1985
X#
X# Modified 10/22/85-James M. Scardelis, SA, Warner Computer Systems
X#       to create newsgroups locally only.
X#
X# Modified April 1989 David Wright  dww@stl.stc.co.uk
X#	to fix bugs in group creation and make directories include parents
X#
X# This program is in the public domain - do with it whatever you like.
X#
X# Be CAREFUL with that active list!  Although we try to write out
X# buffers as quickly as possible, conflicts can occur if someone else
X# tries to use it at the same time this script is running!
X#
X# Actions taken and strange occurences are recorded in mvjunk-log.
X
X# Set DISTRIB to cover your local net or organisation if you want any
X# new groups found to be created across your net.   The default is local only
XDISTRIB=local
X
XJUNK=/usr/spool/news/junk
XSPOOL=/usr/spool/news
XLIB=/usr/lib/news		# See line 121
X
Xumask 22
X
Xchmod u+wr $LIB/active
X
Xcd $JUNK
X
Xif /bin/test -z "`ls`" ; then exit
Xfi
X
Xchmod u+wr *
X
Xfor j in $JUNK/*
Xdo
X	for group in `egrep '^Newsgroups:' $j | head -1 | \
X		sed 's;Newsgroups:[ 	];;' | \
X		sed 's;,; ;g'`
X	do
X		echo "Found article $j for group $group"
X		echo "Found article $j for group $group" >> $LIB/mvjunk-log
X		l=`egrep '^Control:' $j`
X		if /bin/test -n "$l" ; then
X			GROUPDIR="control"
X			group="control"
X		else
X			GROUPDIR=`echo $group | sed 's;\.;\/;g'`
X		fi
X#
X		cd $SPOOL
X		if /bin/test -d $GROUPDIR ; then
X		# Directory exists - work out number of the next article
X			cd $GROUPDIR
X			l=`ls`
X			if /bin/test -n "$l" ; then
X				a=`ls | sort -r -n`
X				for f in $a
X				do
X					if /bin/test -f "$f" ; then
X						article=`echo $f "+1" | bc`
X						break
X					fi
X				done
X			else
X				article=1
X			fi
X		else
X		# No directory for this group - create one, and set art.no = 1
X		# Create parent directories too if they don't exist already
X		dir=$SPOOL
X		for subdir in `echo $group | sed 's;\.; ;g'`
X		do
X			dir=${dir}/${subdir}
X			if /bin/test ! -d "$dir" ; then
X				echo "Creating directory $dir"
X				echo "Creating directory $dir">>$LIB/mvjunk-log
X				mkdir $dir
X			fi
X		done
X		article=1
X		fi
X
X		# Now we know where to put it, put it there,
X		# and update active file too
X		cd $SPOOL/$GROUPDIR
X		if /bin/test ! -d "$article" ; then
X
X			cp $j $SPOOL/$GROUPDIR/$article
X
X			chmod ugo+wr $SPOOL/$GROUPDIR/$article
X			chown news $SPOOL/$GROUPDIR/$article
X			chgrp news $SPOOL/$GROUPDIR/$article
X			the_date=`date`
X			entry=`egrep "^$group " $LIB/active`
X			if /bin/test -z "$entry" ; then
X			    echo \
X			    "Created $the_date to hold articles found in junk"|\
X				$LIB/inews -d $DISTRIB -C $group
X			    echo "Created group $group at $the_date" \
X				>> $LIB/mvjunk-log
X			    entry="$group 00001 00001 y"
X			    echo $entry >> $LIB/active
X			    echo \
X			    "$group	found in junk; created at $the_date" \
X						>> $LIB/localgroups
X			fi
X			entry="^$entry "
X#
X# There should be a way of passing shell variables into awk, but since
X# we don't know how to do that we just hardwire it.  Kludgy... no?
X#
X			echo $article $entry $the_date | \
X				awk 'BEGIN { FS = " " } \
X			{ if ( NF != 11 ) printf "Munged active entry: %s\n",\
X				$0 >"/usr/lib/news/mvjunk-log" ; \
X			if ( length($1) > 5 ) printf "Field too large: %s\n",\
X				$0 >"/usr/lib/news/mvjunk-log" ; \
X			if ( length($3) > 5 ) printf "Field too large: %s\n",\
X				$0 >"/usr/lib/news/mvjunk-log" ; \
X			if ( length($4) > 5 ) printf "Field too large: %s\n",\
X				$0 >"/usr/lib/news/mvjunk-log" ; \
X			printf "/%s/s;%s;",$2,$3 ; \
X			for ( i = 5 - length($1) ; i > 0 ; i-- ) printf "0" ; \
X			print $1 ";" ; \
X			if ( length($4) < 5 ) { \
X			    printf "s;%s;",$4 ; \
X			    for ( i = 5 - length($1) ; i > 0 ; i-- ) printf "0" ; \
X			    print $4 ";" \
X			    } \
X			if ( $5 != "y" && $5 != "n" ) print "s;.$;y;" } \
X			    	END { printf "w\nq\n" }' | ed - $LIB/active
X		else
X		   echo \
X		   "Hey, there's a directory called $SPOOL/$GROUPDIR/$article!"
X		   echo \
X		   "Hey, there's a directory called $SPOOL/$GROUPDIR/$article!"\
X			>> $LIB/mvjunk-log
X		fi
X	done
X	if /bin/test -f $SPOOL/$GROUPDIR/$article ; then
X		/bin/rm -f $j		# But my MOTHER lives in Hackensack!
X	else
X		echo "Couldn't find the article I just installed!"
X		echo "Couldn't find the article I just installed!" >> \
X			$LIB/mvjunk-log
X	fi
Xdone
X
X
X
END_OF_FILE
if test 4680 -ne `wc -c <'mvjunk'`; then
    echo shar: \"'mvjunk'\" unpacked with wrong size!
fi
chmod +x 'mvjunk'
# end of 'mvjunk'
fi
echo shar: End of shell archive.
exit 0



JB
-- 
Jonathan Bayer		Intelligent Software Products, Inc.
(201) 245-5922		500 Oakwood Ave.
jbayer@ispi.COM		Roselle Park, NJ   07204    
Technical Details
Message-ID: <1653@ispi.COM>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmdzi!unido!mcsun!uunet!bu.edu!rpi!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!rutgers!ispi!jbayer
References: <salem.648769862@ace>

Show Full Headers
Complete Article Headers
Message-ID: <1653@ispi.COM>
Subject: Re: Local parsing of junk into news groups.
Date: Tue, 24 Jul 1990 11:31:11 +0000
From: jbayer@ispi.COM (Jonathan Bayer)
References: <salem.648769862@ace>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmdzi!unido!mcsun!uunet!bu.edu!rpi!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!rutgers!ispi!jbayer
Newsgroups: news.software.nn
Organization: Intelligent Software Products, Inc.
Lines: 212
Posted: Tue Jul 24 12:31:11 1990