Article View: news.software.nntp
Article #50649Re: cloning an INN server
From: Russ Allbery
Date: Thu, 15 Feb 2001 23:35
Date: Thu, 15 Feb 2001 23:35
109 lines
5201 bytes
5201 bytes
David Eckhardt <davide+receptionist@cs.cmu.edu> writes:
> I want to clone an INN server. That is, I want a second server with the
> same articles numbered the same way. I understand that xrefslave does
> most of what I want, but I am concerned about a corner case.
xrefslave is the right place to be looking.
> Some of the articles on the old server were posted many years ago to
> groups that we never expire. A few of those articles were also
> crossposted to groups with much shorter expiration times. My old server
> used the traditional spool format for everything, and I expect the new
> one to use it for our local hierarchies (i.e., both newsgroups in
> question).
> From looking at the code, it appears as if one of these articles
> arriving at the new server would be indexed into all of the groups in
> the Xref: header. That is, while the article would appear in only one
> group on the old server, it would appear in both groups on the new
> server.
Right.
> If I initialized the new server with a copy of the old server's active
> file, this re-creation of expired articles would not affect anybody.
> But if I retired the old server and some catastrophe required me to
> rebuild the active file, then the low mark for the non-eternal newsgroup
> would go down, causing readers to reset the group, right?
It may, yeah. The approach I would take is to use this script that I
wrote to solve the exact same problem for our servers; it filters out any
crossposts in the Xref header while copying a tree of articles into a new
directory. You can then use find on that new tree to generate a batch
file for an innxmit that understands how to read files and not storage API
tokens (any innxmit prior to INN 2.3 will work, and so should the version
in INN 2.3.2 when I get a chance to fix it).
#!/usr/bin/perl
$ID = q$Id: fixref,v 1.1 2001/01/10 11:27:37 eagle Exp $;
#
# fixref -- Fix the Xref headers in a tree of news articles.
#
# Written by Russ Allbery <rra@stanford.edu>
# Copyright 2000 Board of Trustees, Leland Stanford Jr. University
#
# Copy a tree of traditional spool news articles, fixing the Xref headers as
# we go. Add Xref headers if missing (based on the path to the article),
# and if an Xref header is present, trim out hierarchies other than those
# given on the command line.
#
# Usage: fixref -a <hierarchy-pattern> <from> <to> <hierarchy>
use strict;
use vars qw($ALLOW $COUNT %DONE $FROM $ID $TO);
use File::Find qw(find);
use File::Path qw(mkpath);
use Getopt::Long qw(GetOptions);
sub copy {
return unless -f $_;
return unless /^\d+$/;
my $path = $File::Find::dir;
$path =~ s%^\Q$FROM\E/*%%;
open (SRC, "< $_") or die "Can't open $File::Find::name: $!\n";
mkpath ("$TO/$path", 0, 0755) unless $DONE{$path}++;
open (DST, "> $TO/$path/$_") or die "Can't open $TO/$path/$_: $!\n";
my $header = 1;
my $havexref = 0;
while ($header) {
my $line = <SRC>;
if ($line =~ /^Xref: /) {
if ($ALLOW) {
my ($xref, $server, @groups) = split (' ', $line);
@groups = grep { /$ALLOW/ } @groups;
$line = join (' ', $xref, $server, @groups) . "\n";
}
$havexref = 1;
} elsif ($line =~ /^[\r\n]*$/) {
unless ($havexref) {
my $group = $path;
$group =~ tr%/%.%;
$group .= ":$_";
print DST "Xref: fixref $group\n";
}
$header = 0;
}
print DST $line;
}
local $_;
print DST while <SRC>;
close SRC;
close DST or die "Can't flush $TO/$path/$_: $!\n";
print "$COUNT articles processed\n" if ((++$COUNT % 100) == 0);
}
GetOptions ('allow|a=s' => \$ALLOW) or exit 1;
my $hierarchy;
($FROM, $TO, $hierarchy) = @ARGV;
die "Usage: fixref [-a <allow>] <from> <to> <hierarchy>\n"
unless $hierarchy;
find (\©, "$FROM/$hierarchy");
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
Please post questions rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Technical Details
Message-ID:
<ylu25vplie.fsf@windlord.stanford.edu>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!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!171.64.14.106!newsfeed.stanford.edu!nntp.stanford.edu!not-for-mailReferences:
<96hj05$2e8$1@cantaloupe.srv.cs.cmu.edu>Show Full Headers
Complete Article Headers
Message-ID: <ylu25vplie.fsf@windlord.stanford.edu> Subject: Re: cloning an INN server Date: Thu, 15 Feb 2001 23:35:53 +0000 From: Russ Allbery <rra@stanford.edu> References: <96hj05$2e8$1@cantaloupe.srv.cs.cmu.edu> 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!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!171.64.14.106!newsfeed.stanford.edu!nntp.stanford.edu!not-for-mail Newsgroups: news.software.nntp Organization: The Eyrie Lines: 108 NNTP-Posting-Host: windlord.stanford.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.Stanford.EDU 982280153 11606 171.64.13.23 (15 Feb 2001 23:35:53 GMT) X-Complaints-To: news@news.stanford.edu User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)