Obviously this is primitive and could use a lot of work. But we've been using
it for two years now to create new lists on our Majordomo host.
Here's what we do to create a new list. Obviously all these hand steps (run as
root) can and will be collected into a script, and maybe even fired up from a
secure authenticated remote SSH connection from a Java GUI frontend, I've just
been too lazy! :-)
cd /var/majordomo/lists
touch listname{,.closed}
echo ["something"] > listname.passwd
mkdir ../archive/listname.archive
chown majordomo.majordom listname* ../archive/listname.archive
[if digestified, also mkdir ../digest/listname.digest, chown & chmod that]
cd ../etc
./buildaliases < lists.attributes > newaliases
cp newaliases /etc/aliases
newaliases
ci -l lists.attributes newaliases
[enter RCS version comment, naming the department responsible for the list]
[we SHOULD be keeping a database of list owners but we're not, yet]
mail standard list owner guide to list owner address
The "buildaliases" takes the lists.attributes file and produces a new copy of
/etc/aliases, first prepending the site-specific static aliases, then
constructing the set of aliases for each list, including the list-digest
aliases where needed.
Chris Koenigsberg
ckk@uchicago.edu, ckk@pobox.com
http://www2.uchicago.edu/ns-acs/ckk/index.html
(also http://www.pobox.com/~ckk)
------ Cut here ------------------
#!/usr/local/bin/perl -- # -*-Perl-*-
# Copyright (c) 1996 Christopher K. Koenigsberg
# (ckk@uchicago.edu, ckk@pobox.com)
# All Rights Reserved. For use by permission only.
#
# Originally written August 1994.
# Usage:
# echo "newlistname:listowner@host:active:monthly:no" >> lists.attributes
# buildaliases < lists.attributes > newaliases
# ci -l lists.attributes newaliases
# cp newaliases /etc/aliases; newaliases
#
# This is supposed to rebuild a new copy of the /etc/aliases file
# First it copies out the common aliases, then reads the lists.attributes
# input file, and loops over them, generating the associated aliases
# for each lists, to the output file.
#
# The lists.attributes file entry, one per list, has five colon-separated
# attributes. List name, list owner address, "active" or "inactive",
# archive frequency ("monthly", "daily", or "none"),
# and digest ("yes" or "no").
#
# $Header$
# THISHOST is the hostname for this aliases file.
# LISTNAME is template list name, LISTOWNER is owner template.
# LISTHOST is template hostname for envelope and return address fields.
# ROOT is where to forward root mail.
# MAJOWN is where to forward majordomo-owner mail.
# WRAPPER is the full pathname of the Majordomo wrapper program.
require 'ctime.pl'; # for printing the current date.
$hashmarks = "#################################################################
#######";
do &init_aliases;
do &common_aliases;
# Format of lists.attributes file: colon-separated (now on stdin).
# @ThisList = ($LISTNAME, $LISTOWNER, $ACTIVE, $ARCHFREQ, $DIGEST);
$NumAttributes = 5;
while (<STDIN>) {
chop;
@ThisList = split(/:/, $_);
if (@ThisList != $NumAttributes)
{die("Need 5 list attrs, got @ThisList instead for $ThisList[0]!\n")};
do &list_aliases(@ThisList);
}
do &end_aliases;
exit 0;
########################################################################
# sub init_aliases
########################################################################
sub init_aliases {
#These should really be an associative array, from an input file?
$THISHOST = "yourhost.domain.name";
$ROOT = "postmaster";
$LISTHOST = $THISHOST;
$MAJHOME = "/var/majordomo";
$MAJOWN = $ROOT;
$WRAPPER = "$MAJHOME/v1.92/wrapper";
$LISTSDIR = "$MAJHOME/lists";
$ARCHIVEDIR = "$MAJHOME/archive";
$StartTime = &ctime(time);
# chop takes the newline off ctime's return string.
chop($StartTime);
}
########################################################################
# sub end_aliases
########################################################################
sub end_aliases {
$end_time = &ctime(time);
chop($end_time); #chop deletes trailing newline.
print <<"EOE";
# End $THISHOST aliases of $end_time.
$hashmarks
EOE
}
#
########################################################################
# sub common_aliases
########################################################################
sub common_aliases {
# Note you could read in from a file, instead of this "here document".
print <<"EOC";
# Aliases for $THISHOST, built by buildaliases Perl script,
# at $StartTime.
# This file will be regenerated from several pieces,
# by a make in $MAJHOME/etc.
# Do not edit this /etc/aliases by hand, or your changes will be lost!
$hashmarks
# Main system aliases.
$hashmarks
#
root: $ROOT
Postmaster: root
MAILER-DAEMON: postmaster
# Local aliases below #
nobody: root
daemon: root
sys: root
bin: root
uucp: root
news: root
ingres: root
audit: root
sync: root
sysdiag: root
sundiag: root
system: postmaster
$hashmarks
# Majordomo List service aliases
$hashmarks
owner-owner: postmaster
majordomo: "| $WRAPPER majordomo"
owner-majordomo: majordomo-owner
majordomo-owner: $MAJOWN
listserv: majordomo
listproc: majordomo
listkeeper: majordomo
listmaster: owner-majordomo
EOC
} #end of sub common_aliases
#
########################################################################
# sub list_aliases
########################################################################
sub list_aliases {
($LISTNAME, $LISTOWNER, $ACTIVE, $ARCHFREQ, $DIGEST) = @_;
$ARCHIVEALIAS = "";
$ARCHFLAG = "-";
$DIGESTALIASES = "";
$OUTGOING = "$LISTNAME-outgoing: :include:$LISTSDIR/$LISTNAME";
# First see if this list is to be archived, with what frequency.
# ARCHFREQ should be one of "none", "daily", "monthly", "yearly".
# We use the first letter for the freq. flag passed to the archive2 script.
$ARCHFREQ =~ /(^.)(.*)/;
$ARCHFLAG .= $1;
if ($ARCHFLAG ne "-n") { #otherwise, no archiving!
# pass the outgoing list msgs through the archive alias too.
$OUTGOING .= ", $LISTNAME-archive";
# create the alias for the archive.
$ARCHIVEALIAS = "$LISTNAME-archive: | \"$WRAPPER archive2 -f
$ARCHIVEDIR/$LISTNAME.archive/$LISTNAME $ARCHFLAG -a\"";
} # end of if $ARCHFLAG ne "n".
# Now see if we do digestification or not.
if ($DIGEST ne "no") {
# pass the outgoing list msgs through the digestification alias too.
$OUTGOING .= ", $LISTNAME-mkdigest";
$DIGESTALIASES = <<"EOD";
$LISTNAME-mkdigest: "| $WRAPPER digest -r -C -l $LISTNAME-digest
$LISTNAME-digest-outgoing"
$LISTNAME-digest: $LISTNAME
$LISTNAME-digest-request: "| $WRAPPER majordomo -l $LISTNAME-digest"
owner-$LISTNAME-digest-request: owner-$LISTNAME
$LISTNAME-digest-approval: owner-$LISTNAME
owner-$LISTNAME-digest-approval: owner-$LISTNAME
$LISTNAME-digest-outgoing: :include:$LISTSDIR/$LISTNAME-digest
owner-$LISTNAME-digest-outgoing: owner-$LISTNAME
EOD
} # end of if $DIGEST eq "no".
#########################
# Now, spit out this list's entry in the new alias file.
print <<"EOT";
$hashmarks
# Begin aliases for $LISTNAME mailing list
# Archiving: $ARCHFREQ, Digestification: $DIGEST, ListOwner: $LISTOWNER.
$LISTNAME: "| $WRAPPER resend -h $LISTHOST -l $LISTNAME $LISTNAME-outgoing"
owner-$LISTNAME: $LISTNAME-owner
$LISTNAME-owner: $LISTOWNER
$LISTNAME-request: "| $WRAPPER majordomo -l $LISTNAME"
$LISTNAME-approval: owner-$LISTNAME
$OUTGOING
owner-$LISTNAME-outgoing: owner-$LISTNAME
$ARCHIVEALIAS
$DIGESTALIASES
# End of $LISTNAME list aliases
$hashmarks
EOT
} # end of sub list_aliases.
#########################################################
References:
|
|