🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
2 messages
2 total messages Started by Steven E. Newton Wed, 03 Mar 1993 16:39
User-Painless server change?
#1720
Author: Steven E. Newton
Date: Wed, 03 Mar 1993 16:39
42 lines
2749 bytes
[ Note crossposting... ]
Greetings,

We here are in the midst of changing over our nntp-based newsreader
users from one nntp server to another, accessed primarily with rrn.
Besides the difference in article numbering, the new server will have
some groups the old one doesn't, and lack some groups the old one has.

A directive has come down from on high that we shall do this in a way
that users who have a minimal knowledge of news and rrn in particular
will have a minimum of disruption.  This means avoid the numerous
"Warning, somebody seems to have reset group.group! Assuming nothing
read!" and "Warning! Bogus group foo.bar" messages from rrn, and not
disrupting each user's subscribed/unsubscribed groups (I.E., can't just
replace everyone's .newsrc with a fresh one).

It appears that the best way to do this would be for each user to run or
have run for them a utility that would compare their .newsrc file with
the active file from the new server, add the new groups, remove the old
ones, and reset the numbering on the subscribed groups to minimize
rereading old article.  The last could be done by comparing the last
read # in the .newsrc with the active file from the old server, getting
a count of unread articles, then resetting the .newsrc last read article
to be the high article # from the new server - the unread count, making
sure the first unread article number is not less than one.

OK, so is there a tool out there that I haven't found so I don't
reinvent the square wheel?  What have you as a news admin done?  Or will
I be a hero by writing said tool?

Tanx in advance,
Steven E. Newton
Academic Computing


-- 
+      +      +      +      +      +      +    |snewton@oac.hsc.uth.tmc.edu
     You can make it foolproof,                |Nobody else speaks for me,
  but you can't make it damnfoolproof.         |and I speak for no one else.
                                               |     +     +     +     +     +
Re: User-Painless server change?
#1722
Author: Evan Kirshenbaum
Date: Wed, 03 Mar 1993 19:41
233 lines
6810 bytes
In article <1n2n0hINNo8a@oac4.hsc.uth.tmc.edu> snewton@oac3.hsc.uth.tmc.edu (Steven E. Newton) writes:
>OK, so is there a tool out there that I haven't found so I don't
>reinvent the square wheel?  What have you as a news admin done?  Or will
>I be a hero by writing said tool?

Well, here's a perl script that I wrote when I wanted to do the same
thing.  No warranties expressed or implied, but it seemed to do a
pretty good job.  It may need a little bit of tweaking.  It requires
that both servers be accessable at the same time.

Enjoy.

Evan Kirshenbaum		       +------------------------------------
    HP Laboratories		       | He who will not reason, is a bigot;
    3500 Deer Creek Road, Building 26U | he who cannot is a fool; and he who
    Palo Alto, CA  94304	       | dares not is a slave.
				       |               Sir William Drummond
    kirshenbaum@hpl.hp.com	       | 
    (415)857-7572

---------------------------Cut Here-------------------------
#!/usr/local/bin/perl

$oldServer = shift || die "No old nntp server specified";
$newServer = shift || die "No new nntp server specified";
$srcFile = shift || "/users/evan/.newsrc";
$newSrcFile = shift || ".newsrc.$newServer";
$unknownGroupFile = "unknown.$newServer";

open(SRCFILE, "<$srcFile") || die "Couldn't open $srcFile";
open(NEWFILE, ">$newSrcFile") || die "Couldn't open $newSrcFile";
open(UNKNOWN, ">$unknownGroupFile") || die "Couldn't open $unknownGroupFile";

$port = 119;
$sockaddr = 'S n a4 x8';
$DOMAIN = 2;
$STYLE = 1;
$rin = $rout = '';

($name, $aliases, $proto) = getprotobyname('tcp');

($name, $aliases, $type, $len, $oldhostaddr) = gethostbyname($oldServer);
$oldSock = pack($sockaddr, $DOMAIN, $port, $oldhostaddr);
socket(OS, $DOMAIN, $STYLE, $proto) || die $!;
connect(OS, $oldSock) || die $!;
select(OS); $| = 1; select(STDOUT);
vec($rin, fileno(OS), 1) = 1;
select($rout=$rin, undef, undef, undef);
$_ = <OS>;
if ($_ !~ /^2../)
{
	print;
	die "Service nntp on $oldServer unavailable";
}

$| = 1;

($name, $aliases, $type, $len, $newhostaddr) = gethostbyname($newServer);
$newSock = pack($sockaddr, $DOMAIN, $port, $newhostaddr);
socket(NS, $DOMAIN, $STYLE, $proto) || die $!;
connect(NS, $newSock) || die $!;
select(NS); $| = 1; select(STDOUT);
vec($rin, fileno(NS), 1) = 1;
select($rout=$rin, undef, undef, undef);
$_ = <NS>;
if ($_ !~ /^2../)
{
	print;
	die "Service nntp on $newServer unavailable";
}

LINE:
while($line=<SRCFILE>)
{
  chop($line);
  $line =~ /[:!]\s*/;
  $group = $`;
  $rangeDesc = $';
  $subscribed = ($& =~ ":");
  if ($rangeDesc =~ /^([0-9]+).*[,-]([0-9]+)$/)
  {
    $firstRead = $1;
    $lastRead = $2;
  }
  else
  {
    $firstRead = $lastRead = $rangeDesc;
  }
  unless ($subscribed)
  {
    $rangeDesc = "$firstRead-$lastRead";
  }
  @ranges = split(/,/,$rangeDesc);
  print STDERR <<EOS;

Group: $group
EOS
  print NEWFILE $group, ($subscribed ? ": " : "! ");
  &writeGroupData if &readGroupData;
  print NEWFILE "\n";
#  exit if ++$count > 4;
}

sub readGroupData
{
  undef %msgIdRead;
  undef @oldRead;
  $firstId = "";
  
  print OS "group $group\n";
  $_ = <OS>;
  ($stat, $num, $first, $last) = split;
  if ($stat !~ /^2../)
  {
    print;
    warn "Group doesn't exist on $oldServer: $group";
    return 0;
  }
  print OS "xhdr message-id $first-$last\n";
  unless (/^2/)
  {
    print;
    warn "Couldn't get ids: $group";
    return 0;
  }
  &nextRange;
  $someSeen = 0;
OLDID:
  while (<OS>)
  {
    last if /^\./;
    chop; chop;
    ($num,$id) = split(/ /,$_,2);
    while ($num > $rangeEnd)
    {
      &nextRange;
    }
    $msgIdRead{$id} = "2" if $num>=$rangeStart;
    $msgIdRead{$id} = "1" unless $num>=$rangeStart;
    $someSeen = 1 if $msgIdRead{$id} == 2;
    print STDERR $msgIdRead{$id};
  }
  return 1;
}

sub nextRange
{
  ($rangeStart,$rangeEnd) = split(/-/,shift(@ranges));
  $rangeEnd = $rangeStart unless $rangeEnd;
  $rangeStart = $rangeEnd = 100000000 unless $rangeEnd;
}

sub writeGroupData
{
  $BEFORE = 0;
  $READ = 1;
  $UNREAD = 2;
  $state = $BEFORE;
  $range = "";

  print STDERR "\n writing:";
  print NS "group $group\n";
  $_ = <NS>;
  ($stat, $num, $first, $last) = split;
  if ($stat !~ /^2../)
  {
    print;
    warn "Group doesn't exist on $newServer: $group";
    print UNKNOWN "$group\n";
    return 0;
  }
  unless ($someSeen)
  {
    print STDERR "<None seen>\n\n";
    return 1;
  }
  $lastUnknown = $first-1;
  print NS "xhdr message-id $first-$last\n";
  $_ = <NS>;
  unless (/^2/)
  {
    print;
    warn "Couldn't get ids: $group";
    return 0;
  }
NEWID:
  while (<NS>)
  {
    last if /^\./;
    chop; chop;
    $lastNum = $num;
    ($num,$id) = split(/ /,$_,2);
    print STDERR $msgIdRead{$id} || "0";
    if ($msgIdRead{$id}==2)
    {
      $rangeFirst=1 if ($state == $BEFORE);
      $rangeFirst = $num if ($state == $UNREAD);
      &addRange(1,$lastUnknown) if ($lastUnknown && $state == $UNREAD);
      $lastUnknown = 0;
      $lastRead = $num;
      $state = $READ;
      next NEWID;
    }
    if ($msgIdRead{$id}==1)
    {
      &addRange($rangeFirst,$lastNum) if ($state == $READ);
      $state = $UNREAD;
      next NEWID;
    }
    if ($msgIdRead{$id}==0)
    {
      next NEWID if ($state == $READ && $rangeFirst == 1);
      $lastUnknown = $num if ($state == $BEFORE);
      &addRange($rangeFirst,$lastNum) if ($state == $READ);
      $state = $UNREAD if ($state == $READ);
      next NEWID;
    }
  }
  &addRange($rangeFirst,$lastRead) if ($state == $READ);
  print NEWFILE "$range";
  print STDERR "\n   $range\n";
}

sub addRange
{
  local($start,$end) = @_;
  return unless $end>=$start;
  print STDERR "[$start-$end]";
  $range .= "," if $range;
  $range .= "$start-$end" unless $start==$end;
  $range .= "$start" if $start==$end;
}
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