Article View: news.software.nntp
Article #19028Possible solution for keeping control.* clean
From: Scott W. Gifford
Date: Sat, 05 Jul 1997 00:00
Date: Sat, 05 Jul 1997 00:00
155 lines
5314 bytes
5314 bytes
All of the posts that I've seen here about keeping the control newsgroups
under...well, control...have involved either gigantic patches to INN, or
else have simply blown away all of the articles in the control.* groups
every hour or so, and taken the chance of not propagating control messages
for backlogged feeds. It seems to me you can get the simplicity of the
"blow it all away" approach without the danger by simply scanning the
outgoing batch files, and leaving any files which have not yet been sent
around until they are.
Here's my first attempt at doing so...It's just a Perl script that I run
from Cron every hour or so. It has only been rudimentarily tested, so use
at your own risk. Run with "-Vn" switches to see what it would do without
actually doing anything.
If you currently have a lot of articles in your control.* groups, run
this once manually, then re-create the directories to make them shrink down
to a reasonable size. For example:
mv control/cancel control/cancel.OLD
mkdir control/cancel.NEW
mv control/cancel.OLD/* control/cancel.NEW
rmdir control/cancel.OLD
Enjoy! Let me know if you have any problems or improvements, or for some
reason this turns out to be just a tremendously bad idea...
-----Scott.
#!/usr/local/bin/perl
# cleanifprop - Remove all articles in a newsgroup except
# ones which have not yet propogated to downstream sites.
# Set this to the dir with innshellvars.pl
$INNDIR="/usr/local/news/etc";
# Set this to the newsgroups to be cleaned.
@CLEANGROUPS=("control.cancel","control");
# You shouldn't have to touch anything below here.
# But if you want to, have a ball...
# $Id: cleanifprop,v 1.3 1997-07-05 03:12:40-04 sgifford Exp $
#
# $Log: cleanifprop,v $
# Revision 1.3 1997-07-05 03:12:40-04 sgifford
# Reformatted for posting to USENET.
#
# Revision 1.2 1997-07-05 03:02:28-04 sgifford
# Initial Release
#
#
require "getopts.pl";
&Getopts("vVn");
$verbose=$opt_v||$opt_V;
$veryverbose=$opt_V;
$noaction=$opt_n;
push(@INC,$INNDIR);
require "innshellvars.pl";
# Clean out all files from directories which have been propogated
# to all outgoing feeds. Mostly useful for control.cancel, to
# keep the directory lean and mean without affecting cancel
# propogation.
# Change the dots to slashes in @CLEANGROUPS
foreach (@CLEANGROUPS)
{
s/\./\//g;
push(@CLEANDIRS,$_);
}
# Take a snapshot of all of our out.going files.
# If it's in the batch directory, assume it's really a batch
# file. If you think I'm going to parse all of newsfeeds
# just to find out which are real outgoing batches, you're nuts...
$verbose && print "Scanning outgoing batches in $inn::batch...\n";
chdir($inn::batch) || die "Couldn't chdir($inn::batch) (BATCHDIR)";
opendir(BATCH,".");
while ($out_going=readdir(BATCH))
{
next if (($out_going eq ".") || ($out_going eq ".."));
$verbose && print "\tScanning $inn::batch/$out_going...\n";
open(OUT_GOING,$out_going);
while (<OUT_GOING>)
{
# Lines in the out.going files look like this:
# alt/test/197780 <01bc8903$d612e140$d8298acd@sgifford.tir.com>
($grp,$art)=m|^(.*)/([0-9]*) |;
if (grep(/^$grp$/,@CLEANDIRS))
{
$saveart{"$grp/$art"}=1;
$veryverbose && print "\t\tSaving $grp/$art.\n";
}
}
close(OUT_GOING);
$verbose && print "\tDone scanning $inn::batch/$out_going.\n";
}
closedir(BATCH);
$verbose && print "Done scanning outgoing batch files in ",
"$inn::batch\n";
# OK, we have our saved articles...Now go into the spool directory
# and fry them.
$verbose && print "Cleaning up spool directory $inn::spool...\n";
# Let's make sure their spool directory is where they say it
# is, just to be nice.
chdir($inn::spool) || die "Couldn't chdir($inn::spool) (SPOOL)";
foreach $groupdir (@CLEANDIRS)
{
# There shouldn't be that many groups, so don't try to be fancy
# about getting there.
unless (chdir("$inn::spool/$groupdir"))
{
warn "WARNING: Skipping $inn::spool/$groupdir: " .
"Couldn't chdir($inn::spool/$groupdir)";
next;
}
$verbose && print "\tCleaning $inn::spool/$groupdir\n";
# Flip through the articles
opendir(ARTICLES,".");
while ($art=readdir(ARTICLES))
{
# Skip over things that don't look like articles.
next unless ($art =~ /[0-9]+/);
# Perl unlink won't delete dirs, so just fire away...
unless ($saveart{"$groupdir/$art"})
{
$veryverbose && print "\t\tunlink($art)\n";
unlink($art) unless $noaction;
}
}
$verbose && print "\tDone cleaning $inn::spool/$groupdir\n";
closedir(ARTICLES);
}
$verbose && print "Done cleaning up spool directory $inn::spool.\n";
Technical Details
Message-ID:
<01bc8913$1adff4c0$d8298acd@sgifford-home.tir.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <01bc8913$1adff4c0$d8298acd@sgifford-home.tir.com> Subject: Possible solution for keeping control.* clean Date: Sat, 05 Jul 1997 00:00:00 +0000 From: "Scott W. Gifford" <sgifford@tir.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 254727436 Organization: Oftwaresay Newsgroups: news.software.nntp