🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #34516

Re: Cleaning up timehash newsgroups

#34516
From: Fluffy
Date: Sat, 09 Jan 1999 00:00
76 lines
3277 bytes
Gary Mills <mills@cc.umanitoba.ca> wrote:
> We have a number of local newsgroups that I've set up with an 150-day
> expiry.  Occasionally, I'm asked to remove all the articles so they
> can start fresh.  With the traditional spool, I just removed the files.
> How can I accomplish the same thing with timehash storage?  Can I just
> move the groups to a different storage class in storage.conf, wait for
> expire to run, and then move them back?  Is there a more direct way?

Please take this seriously:

Leave the deletion line commented out and verify that this script works
properly on your system before letting it rip.  It works for me, it may
or may not work for you.  In particular I'm not sure about endianness
issues, see the unpack stuff.  If anything non-good happens to your
spool, I don't want to hear about it.

You have been warned.


#!/usr/bin/perl -w
#
#  This script reads the .overview.index for a newsgroup
#  and erases all its articles.  For INN 2 with unified
#  overview.  Tested only on an intel system.
#
BEGIN {
  ### As always, fix this line to match your site. ###
  require "/news/sm/lib/innshellvars.pl";
}
use strict;
use integer;

my ($froup, $novindex, %idhash, %token, $thingy);

print "Newsgroup to clean: ";
chomp ($froup = <>);
$novindex = $froup;
$novindex =~ s/\./\//g;
$novindex =  "$inn::overviewdir/$novindex/$inn::overviewname.index";
print "newsgroup: $froup\n";
print "NOV index: $novindex\n";

die "Index not found!" if ! (-f $novindex);

open NOVIX, $novindex;

# pull the ID hashes out of the overview index
#
### Do these unpacks work the same across systems?  I wrote this on an
### intel system; beware if you're on a different architecture.
#
for (;;) {
  last unless sysread(NOVIX, $thingy, 20);
  $idhash{unpack('N', substr($thingy, 0, 4))} =
  '[' . uc unpack('H*', substr($thingy,4)) . ']';
}

# A bazillion calls to grephistory may be slow, but it's easy.
for (keys %idhash) {
  chomp ($token{$_} = `$inn::newsbin/grephistory $idhash{$_}`);
}
close GREPHISTORY;

for(sort keys %token) {
  print "$_\t$idhash{$_}\n\t$token{$_}\n";
  ###
  ### This does the actual removing.  It's commented out so
  ### you'll remember to make sure to check that the ID
  ### hashes and tokens are sane before you use it for real.
  ###
  ###system("$inn::newsbin/sm", '-d', $token{$_});
}
-- 
"Meow."  --me

Technical Details
Message-ID: <slrn79e5hd.jlq.gerglery@meowhost.meow.invalid>
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
References: <776j6t$n6s$1@canopus.cc.umanitoba.ca>

Show Full Headers
Complete Article Headers
Message-ID: <slrn79e5hd.jlq.gerglery@meowhost.meow.invalid>
Subject: Re: Cleaning up timehash newsgroups
Date: Sat, 09 Jan 1999 00:00:00 +0000
From: gerglery@usa.net (Fluffy)
References: <776j6t$n6s$1@canopus.cc.umanitoba.ca>
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: 430490305
Mail-Copies-To: never
X-Notice: should be reported to postmaster@ibm.net
X-Complaints-To: postmaster@ibm.net
X-Trace: 9 Jan 1999 08:41:23 GMT, 129.37.99.72
Organization: Kitty Porn Distribution, Ltd.
X-URL: http://members.tripod.com/~gerglery/
X-P-Meow: Meow
Cancel-Lock: sha1:3EfaEREvbPp5MegQHeDE74Ap3g8=
Newsgroups: news.software.nntp
X-P-Tickle: Mixy