🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
5 messages
5 total messages Started by Gary Mills Sat, 09 Jan 1999 00:00
Cleaning up timehash newsgroups
#34533
Author: Gary Mills
Date: Sat, 09 Jan 1999 00:00
12 lines
1022 bytes
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?


-- 
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-

Re: Cleaning up timehash newsgroups
#34516
Author: 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

Re: Cleaning up timehash newsgroups
#34564
Author: Gary Mills
Date: Mon, 11 Jan 1999 00:00
12 lines
1250 bytes
In <77d19j$nop@meow.invalid> meowing@banet.net (Fluffy) writes:

>Nifty.  You've got big-endian hardware, right?  If so, that'll make it
>easier to generalize this stuff into something a little more useful.

Yes, I forgot to mention that.  It's a Sun Sparc-20, so the unpacks
are endian-independant.

-- 
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-

Re: Cleaning up timehash newsgroups
#34576
Author: Fluffy
Date: Mon, 11 Jan 1999 00:00
16 lines
1453 bytes
Gary Mills <mills@cc.umanitoba.ca> wrote:
> Thanks, Fluff, it works almost perfectly.  I haven't uncommented the
> `removing' line, but I've verified that it identifies the correct
> articles with `sm -o TOKEN'...

Nifty.  You've got big-endian hardware, right?  If so, that'll make it
easier to generalize this stuff into something a little more useful.

> Name "main::GREPHISTORY" used only once: possible typo

Oops.  Left over from wishful thinking that grephistory -s might
understand tokens.
-- 
"Meow."  --me

Re: Cleaning up timehash newsgroups
#34584
Author: Gary Mills
Date: Mon, 11 Jan 1999 00:00
30 lines
2198 bytes
In <slrn79e5hd.jlq.gerglery@meowhost.meow.invalid> gerglery@usa.net (Fluffy) writes:

>#!/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.
>#

Thanks, Fluff, it works almost perfectly.  I haven't uncommented the
`removing' line, but I've verified that it identifies the correct
articles with `sm -o TOKEN'...

<news@setup16:298>$ E_2_2-1999-01-09_03-01/site/ngclean                      <
Name "main::GREPHISTORY" used only once: possible typo at /usr/local/src/inn/inn-STABLE_2_2-1999-01-09_03-01/site/ngclean line 43.
Newsgroup to clean: local.cs208
newsgroup: local.cs208
NOV index: /usr/local/news/spool/overview/local/cs208/.overview.index
362     [CA2A232B2B0E5843D851F681F0DCA6BF]
        @02023680664E0194000000000000000000008C000000F28500A60000@
363     [F75A5091756031ABAAB3B29A3145C303]
        @02023680664E0195000000000000000000008C000000F32C00D10000@
<news@setup16:299>$ sm -o @02023680664E0194000000000000000000008C000000F28500>
Questions       Richard <a_student@cc.umanitoba.ca>      Mon, 03 Aug 1998 17:41:57 -0400 <35C62EA5.EF70A1CD@cc.umanitoba.ca>             884     11      Xref: setup16.cc.umanitoba.ca local.cs208:362
<news@setup16:302>$ 

-- 
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads