Thread View: news.software.nntp
2 messages
2 total messages
Started by Craig Shrimpton
Sat, 13 Jul 1996 00:00
Need suggestions on replacing the active file.
Author: Craig Shrimpton
Date: Sat, 13 Jul 1996 00:00
Date: Sat, 13 Jul 1996 00:00
14 lines
935 bytes
935 bytes
Folks, I'm currently running INN on FreeBSD and I carry about 10,000 groups. I want to add the full feed as defined in UUNET's active / newsgroups file as I am getting thousands of unwanteds. Should I "sed-zap" UUNET's active file to all zeros and do a ctlinnd renumber, or should I merge my old active with the new in some fashion? Adding 6000+ entries by hand would be a nightmare! Thanks, Craig
Re: Need suggestions on replacing the active file.
Author: John Milburn
Date: Mon, 15 Jul 1996 00:00
Date: Mon, 15 Jul 1996 00:00
161 lines
6086 bytes
6086 bytes
[Posted and mailed. Bogus inet dist removed.]
craigs@os.com (Craig Shrimpton) writes:
>I'm currently running INN on FreeBSD and I carry about 10,000 groups. I want
>to add the full feed as defined in UUNET's active / newsgroups file as I am
>getting thousands of unwanteds. Should I "sed-zap" UUNET's active file to all
>zeros and do a ctlinnd renumber, or should I merge my old active with the new
>in some fashion? Adding 6000+ entries by hand would be a nightmare!
I use this to sync the local active file to that of a remote site. It
retains all low and highwater marks from any existing groups in the
existing active file, and sets all new groups to be zero padded. It
also deletes any existing groups which do not exist in the remote
site, unless specifically flagged as a local group (in $localgroup).
If you don't have getlist access to the site from which you want to
update, you can just grab a file, and change the open call for the
NLIST handle.
This script creates a new active file (active.new), and optionally
installs it (throttle server, mv new active into place, reload active,
ctlinnd go).
The script does not handle group aliases yet (= flag in field 4).
-jem
John Milburn
Pohang, Korea
#!/usr/bin/perl
# $Header: /inn/bin/RCS/update_active,v 1.3 1995/11/15 05:30:13 news Exp news $
# Grabs the active file from a remote server, extracts newsgroups from
# selected hierarchies, and adds them to the local active file.
# optionally, can install and 'makeactive' the new list.
#
# INN specific
# John Milburn Postech, Korea
($program = $0) =~ s%.*/%%;
$newsdir = "/usr/local/news"; # Where your active and history files are kept
$newsbin = "$newsdir/bin"; # Where most INN programs are kept
$nntpserver = "some.big.news.server"; # The name of the server you
# want to get the active list from
chop ($thishost = `hostname`); # Figure out my hostname, to put in local traps.
# command to get the remote active file
$listcommand = "$newsbin/getlist -h $nntpserver active";
$active = "$newsdir/active"; # The active file
$newactive = "$newsdir/active.new"; # Where to put the generated active file
# Modify the following line to remove groups which you don't carry,
# and add any local groups. junk and control should be kept here.
$localgroups = "^junk|^control|^local\.";
# Modify this line to list all hierarchies which you want to receive.
$remotegroups = "^[a-z]";
# Make sure we can write the output file before starting
open(NACTIVE, "> $newactive") || die "$program: can't open new active file $newactive\n";
# Make sure the active file exists
open(ACTIVE, $active) || die "$program: can't open the existing active file $active\n";
# Make sure we can connect to the NNTP server
open(NFILE, "$listcommand |") || die "$program: can't get active list from $nntpserver\n";
# This loop grabs groups from the existing active file which
# are not expected to change, or which _must_ exists (control, junk),
# or which are local, and not available from the server.
while ( <ACTIVE> ) {
($group) = /^(\S+)\s.*$/;
push(@ogroups,$group . "\n");
($group, $high, $low, $mode) = /^(\S+)\s(\S+)\s(\S+)\s([ymxj])$/;
# Save the high and low marks for currently active groups
$highmark{$group} = $high;
$lowmark{$group} = $low;
# Save local groups (which may not exist on the remote server
if (/$localgroups/){
push(@ngroups,$group . "\n");
print NACTIVE "$group $high $low $mode\n";
}
}
close(ACTIVE);
while (<NFILE>) {
if (/$remotegroups/){
if (! /$localgroups/) {
($group, $high, $low, $mode) = /^(\S+)\s(\S+)\s(\S+)\s([ymxj])$/;
push(@ngroups,$group . "\n");
# Use the existing high and low marks, else fill with zeros
# for a new group.
$high = $highmark{$group} || ($high = "0000000000");
$low = $lowmark{$group} || ($low = "0000000000");
print NACTIVE "$group $high $low $mode\n";
}
}
}
# Cleanup
close(NFILE);
close(NACTIVE);
# Make a marker, used for getting the difference array
local(%mark);
# Load the marker with the old groups
grep($mark{$_}++,@ogroups);
# Shove anything not marked into the 'added' array
@added = grep(!$mark{$_},@ngroups);
# Re-set the marker
local(%mark);
# Load with all new groups
grep($mark{$_}++,@ngroups);
# Shove anything not marked into the 'deleted' array
@deleted = grep(!$mark{$_},@ogroups);
print "Groups added:\n";
print " @added\n";
print "Groups removed:\n";
print " @deleted\n";
print "\n";
print "Doing the next step is dangerous, and could trash your active file.\n";
print "Please be absolutely sure that the new active file is correct before\n";
print "using the automatic install feature.\n\n";
print "Would you like me to install the new active file (y/n)? ";
chop($ans = <STDIN>);
if ( $ans =~ /[Yy]/ ) {
print "Installing...\n";
`$newsbin/ctlinnd throttle 're-building active'`;
sleep 5;
rename($active,"$active.old");
rename($newactive,$active);
`$newsbin/makeactive -o >$newactive`;
rename($newactive,$active);
chown((getpwnam("news"))[2,3], $active);
chmod 0644, $active;
`$newsbin/ctlinnd reload active 're-building active'`;
`$newsbin/ctlinnd go 're-building active'`;
}
print "\n";
exit $?;
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