[news.software.b] Automatic updating of $NEWSCTL/moderators

mrl@uai.com (Mark R. Ludwig) (04/09/91)

How is the $NEWSCTL/moderators file updated?  I assume it's via
another of the auto-magical control files similar to the checkgroups
message.  Does it matter which transport system I'm using?  (I'm using
C News as of Dec '90.)  How often are the control files sent?  Which
newsgroup carries it?  Does one control file do all the hierarchies?
For example, I seem to be missing ``gnu.*''.  I've checked the
./notebook, and c-news.doc, reviewed the Nutshell book, and wandered
through the $NEWSBIN directory structure, and I don't see anything
about this file.  I'm sure I've missed something, but I sure can't
find it....$$
-- 
PATH: mrl@uai.com
UUCP: uunet!uaisun4!mrl
PSTN: 213/822-4422
USPS: 7740 West Manchester Boulevard, Suite 208, Playa del Rey, CA  90293

henry@zoo.toronto.edu (Henry Spencer) (04/10/91)

In article <1991Apr9.153347.9797@uai.com> mrl@uai.com (Mark R. Ludwig) writes:
>How is the $NEWSCTL/moderators file updated?  I assume it's via
>another of the auto-magical control files similar to the checkgroups
>message...

Nope.  In fact, I'm not sure precisely what you're thinking of; there is
no NEWSCTL/moderators file supported in C News at all.  If you're thinking
of NEWSCTL/mailpaths, that necessarily has to be updated manually because
its contents are mailer-dependent.
-- 
"The stories one hears about putting up | Henry Spencer @ U of Toronto Zoology
SunOS 4.1.1 are all true."  -D. Harrison|  henry@zoo.toronto.edu  utzoo!henry

davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (04/10/91)

In article <1991Apr9.171428.12907@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:

| Nope.  In fact, I'm not sure precisely what you're thinking of; there is
| no NEWSCTL/moderators file supported in C News at all.  If you're thinking
| of NEWSCTL/mailpaths, that necessarily has to be updated manually because
| its contents are mailer-dependent.

  But when you see the postings you can write an awk script (or sed,
perl, whatever) to reparse it.

  What I do is to store the posting, then have cron run a makefile which
runs the script, saves the corrected form, and builds the new mailpaths
file from the various parts, some of which are local groups, like the
starix and capdist hierarchies.

  There used to be a moderators file, I know it was used for something,
I've got files by that name on some old news machines.
-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
        "Most of the VAX instructions are in microcode,
         but halt and no-op are in hardware for efficiency"

mrl@uai.com (Mark R. Ludwig) (04/10/91)

In article <3322@crdos1.crd.ge.COM>, davidsen@crdos1 (Wm E Davidsen Jr) writes:
>In article <1991Apr9.171428.12907@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
>
>| Nope.  In fact, I'm not sure precisely what you're thinking of; there is
>| no NEWSCTL/moderators file supported in C News at all.  If you're thinking
>| of NEWSCTL/mailpaths, that necessarily has to be updated manually because
>| its contents are mailer-dependent.
>
>  There used to be a moderators file, I know it was used for something,
>I've got files by that name on some old news machines.

Okay, I checked the dates of the files in the directory, and it looks
like the ``moderators'' file came with one of the newsreaders my users
wanted (vnews to be precise).  Thanks for the info!  The neophyte is
learning.$$
-- 
PATH: mrl@uai.com
UUCP: uunet!uaisun4!mrl
PSTN: 213/822-4422
USPS: 7740 West Manchester Boulevard, Suite 208, Playa del Rey, CA  90293

dglo@ADS.COM (Dave Glowacki) (04/13/91)

In article <3322@crdos1.crd.ge.COM> davidsen@crdos1.crd.ge.com (bill davidsen) writes:
>  What I do is to store the posting, then have cron run a makefile which
>runs the script, saves the corrected form, and builds the new mailpaths
>file from the various parts, some of which are local groups, like the
>starix and capdist hierarchies.

You don't even need the cron job.  This perl script is run from ~news/sys
on every article received in news.lists.  It creates a mailpaths
file *and*, as a special bonus, a file suitable for inclusion in
a sendmail aliases file.

#!/usr/local/bin/perl
#
# Extract a list of mail addresses for moderated newsgroups
#  from the monthly posting in news.lists.
# Combine this list with any addresses for local moderated
#  groups to build the C news 'mailpaths' file.
#
# To install:
# 1) Check the MODALIASES, LOCALALIASES, BASEMAILPATHS and MAILPATHS variables
#    to make sure they're correct.
# 2) Install this someplace where it can be run by news.
# 3) Add a line like this to your ~news/sys file (this line works in C news.)
#
#	MODALIAS:world,usa,ca,ba,ads,local,news.lists:\
#			m:/some/place/build-mailpaths
#
# $Header: /var/news/src/ADS-scripts/RCS/build-mailpaths,v 1.5 1991/03/07 19:14:35 dglo Exp $

# subroutine to read in the C news environment
#
$NEWSCONFIG='/usr/lib/news/bin/config';
%NEWSENV = ();
sub newsconfig {
  if (open(NEWSENV, "sh -x $NEWSCONFIG 2>&1  |")) {
    while (<NEWSENV>) {
      $NEWSENV{$1} = $2 if (/(.*)=(.*)\n/);
    }
    close(NEWSENV);
    1;
  } else {
    0;
  }
}

# News locations (handle both C news and B news)
#
if (&newsconfig()) {
  $NEWSARTS = $NEWSENV{'NEWSARTS'};
  $NEWSCTL = $NEWSENV{'NEWSCTL'};
} else {
  $NEWSARTS='/usr/spool/news';
  $NEWSCTL='/usr/lib/news';
}
$MODALIASES = "$NEWSCTL/moderated-aliases";
$LOCALALIASES = "$NEWSCTL/local-moderated-aliases";
$BASEMAILPATHS = "$NEWSCTL/base-mailpaths";
$MAILPATHS = "$NEWSCTL/mailpaths";

# see if the result is supposed to be mailed somewhere
#
$maillist = '';
while (@ARGV > 0) {
  $_ = pop(ARGV);
  $maillist .= ' ' . $_;
}

# either write to a temp file (to be possibly mailed) or to STDOUT
#
if ($maillist) {
  $tmpfile = "/tmp/mperrs.$$";
  open(TMPFILE, ">$tmpfile") || die "Can't open a temporary file!\n";
} else {
  open(TMPFILE, ">-") || die "Couldn't send output to STDOUT!\n";
  select(TMPFILE); $| = 1; select(STDOUT);
}

# only process updated list of moderators
#
while (<>) {
  chop;
  exit if (/^$/);
  last if (/^Subject: List of Moderators/);
}

# skip everything until the :------- line
#
$_ = <> until ((/^:--/) || eof());
exit if (eof());

# process all the moderated list aliases
#
if (!open(MODFILE, ">$MODALIASES")) {
  print TMPFILE  "Couldn't write to '$MODALIASES'!\n";
} else {
  while (<>) {
    chop;
    last if (/^$/);
    ($alias,$address) = split;
    $alias =~ s/\./-/g;
    print MODFILE $alias,":\t",$address,"\n";
  }
  close(MODFILE);

  # get rid of the last backup mailpaths file
  #
  if ( -f "$MAILPATHS.old" ) {
    $i = unlink "$MAILPATHS.old";
    print TMPFILE "Couldn't unlink '$MAILPATHS.old'!\n" if ($i < 1);
  }

  # backup the current mailpaths file
  #
  print TMPFILE "Couldn't backup '$MAILPATHS'!\n"
    if (! rename($MAILPATHS, "$MAILPATHS.old"));


  if (! open(MAILPATHS, ">$MAILPATHS")) {
    print TMPFILE "Couldn't create new '$MAILPATHS'!\n";
  } else {
    &catmailpaths($MODALIASES);
    &catmailpaths($LOCALALIASES);
    &catmailpaths($BASEMAILPATHS);
    close(MAILPATHS);
  }
}

sub catmailpaths {
  local($filename) = @_;

  if ( -f $filename ) {
    if (! open(FILE, $filename)) {
      print TMPFILE "Couldn't read '$filename'!\n";
    } else {
      while (<FILE>) {
	print MAILPATHS $_;
      }
      close(FILE);
    }
  }
}

# mail the report (if there's something to mail)
#
if ($maillist) {
  system "Mail -s 'build-mailpaths errors' $maillist < $tmpfile"
	if ( -s $tmpfile );
  unlink $tmpfile;
}
exit 0;


--
Dave Glowacki          dglo@ads.com          Advanced Decision Systems