On Fri, 22 Nov 1996, Per Idoff T/ED (Cap Gemini) wrote:
> Hi,
>
> It seems to me like most of the questions posted here concern
> problems setting up and configuring lists. I'm sure a lot of you
> people out there have your own scripts to simplify this process.
>
> Who is willing to share?
The following is a script I wrote recently and finished testing today.
_/ _/_/_/ _/ ____________ __o
_/ _/ _/ _/ ______________ -\<,
_/ _/ _/_/_/ _/ _/ ........O/ O
_/_/ oe _/ _/. _/_/ ah jjah@cloud.ccsf.cc.ca.us
#!/usr/local/bin/perl
# Script name: list Location: Majordomo home directory
# Owner: majordom Run by: majordom (su - majordom)
# This is an interactive script to create and/or Remove Majordomo Lists;
# It creates all the necessary files and directories for your lists.
# You can create lists with archives and/or digests or neither.
# It assumes there is an aliases file in majordomo home directory; it
# writes aliases to it and/or removes aliases from it. After it's done
# with its modifications to the aliases file it runs newaliases program.
# In addition, for every list created it will send a helpful message to
# the list owner informing him about the status of his list. It also adds
# the owner to a list, mj-owners, maintained by you to keep your list
# managers informed about Majordomo updates and/or maintenance etc.
# When you remove lists it will not only cleans up list directories and
# files, but also it removes all the corresponding aliases from the
# aliases file as well. Then it runs newaliases program.
#
# Written by: Joe R. Jah
#
require "majordomo.cf";
switch:{
print"Choose one from the following menu:\n";
print"\t[1] Create list(s)\n\t[2] Remove list(s)\n\t[3] Exit\n";
print"Your choice? "; chop($c=<STDIN>);
if($c==1){&create; redo;}
if($c==2){&remove; redo;}
if($c==3){last;}
print"$c is an illegal choice.\n";
redo;
}
sub create{
for($yo='y';$yo=~/[Yy]/;print("Another owner [Ny]? "),chop($yo=<STDIN>)){
print"Enter list owner's email: "; chop($owner=<STDIN>);
print"Does the owner require digest [Ny]? "; chop($yd=<STDIN>);
print"Does the owner require archive [Ny]? "; chop($ya=<STDIN>);
for($y='y';$y=~/[Yy]/;print("Another list [Ny]? "),chop($y=<STDIN>)){
print"Enter list name: "; chop($list=<STDIN>);
unless($list=~/[a-z0-9_-]/){
print"list name can only be made of a-z, 0-9, - ,or _\n";
redo;
}
if(-f "$listdir/$list"){
print"\tlist $listdir/$list already exists\n";
redo;
}
&aliassage;
&dirfile;
#
# Add list aliases to aliases file
#
if($ya=~/[Yy]/&&$yd=~/[Yy]/){$alias=$listad;}# + digest + archive
elsif ($yd=~/[Yy]/){$alias=$listd; }# + digest
elsif ($ya=~/[Yy]/){$alias=$lista; }# + archive
else {$alias=$listo; }#
open(ALIAS,">>$homedir/aliases")||die"Can't open aliases: $!";
print ALIAS"$alias";
close(ALIAS);
#
# Send a message to the owner
#
open(MAIL,"|mail -s \"$list mailing list\" $owner")||die"$!";
print MAIL $message;
close(MAIL);
#
# Add the list owner to mj-owners mailing list
#
open(MJ,"<$listdir/mj-owners")||die"$!";
while(<MJ>){
$isin=1 if /$owner/;
}
close(MJ);
if ($isin!=1){
open(MJ,">>$listdir/mj-owners")||die"$!";
print MJ"$owner\n";
}
close(MJ);
}
}
`newaliases`; # run newaliases
}
sub dirfile{ # Creat the list and add the owner to it
open(L,">$listdir/$list")||die"$!";print L"$owner";close(L);
if($yd=~/[Yy]/){ # Creat the digest list and directories
open(D,">$listdir/$list-digest")||die"$!";print D"$owner";close(D);
mkdir("$digest_work_dir/$list-digest",0775)||die"$!";
mkdir("$listdir/$list-digest.archive",0775)||die"$!";
}
if($ya=~/[Yy]/){ # Creat the archive directory
mkdir("$listdir/$list.archive",0775)||die"$!";
}
}
sub remove{ # Remove obsolete lists and their aliases
for($y='y';$y=~/[Yy]/;print("Another list [Ny]? "),chop($y=<STDIN>)){
print"Enter list name: "; chop($list=<STDIN>);
`rm -r $digest_work_dir/$list-digest > /dev/null 2>&1`;
`rm -r $listdir/$list-digest.archive $listdir/$list > /dev/null 2>&1`;
`rm -r $listdir/$list.archive $listdir/$list-digest > /dev/null 2>&1`;
open(ALIAS,"<$homedir/aliases")||die"Can't open aliases: $!";
for($i=0;<ALIAS>;$i++){
$alias[$i]=$_;
}
close(ALIAS);
open(ALIAS,">$homedir/aliases")||die"Can't open aliases: $!";
for($i=0;$i<=$#alias;$i++){
print ALIAS $alias[$i] unless $alias[$i]=~ /$list\W/;
}
close(ALIAS);
}
`newaliases`;
}
sub aliassage{ # Set aliases and owner message
$message= <<"END";
Your mailing list "$list" is ready for configuration.
Your default password is $list.admin.
You can study Majordomo list-owner commands by browsing
Majordomo List Owner's Guide at:
http://www.uchicago.edu/a.docs/Mail/majordomo.admin.html
To get general help send the following command to
Majordomo\@$whereami:
help
To configure your list send the following command to Majordomo:
config $list $list.admin
forward the configuration to Majordomo and as the first line
of the message type:
newconfig $list $list.admin
To add a description to the list send the following command
as the first line of a message to Majordomo:
newinfo $list $list.admin
continue the message with the description of the list
To subscribe someone other than yourself to the list
send the following command to Majordomo:
approve $list.admin subscribe $list someone\@host.domain
#
# $list mailing list with archive and digest
#
$list:"|$homedir/wrapper resend -l $list -h $whereami $list-outgoing"
$list-digest:$list
$list-outgoing::include:$listdir/$list,
"| $homedir/wrapper digest -r -C -l $list-digest $list-digest-outgoing",
"| $homedir/wrapper archive2.pl -a -m -f $listdir/$list.archive/$list"
$list-digest-outgoing::include:$listdir/$list-digest
owner-$list-digest:owner-$list
owner-$list-digest-outgoing:owner-$list
$list-request: "|$homedir/wrapper request-answer $list"
$list-digest-request: "|$homedir/wrapper request-answer $list-digest"
owner-$list:$owner,
owner-$list-outgoing:owner-$list
$list-approval:$owner,
$list-digest-approval:$list-approval
END
$listd= <<"END";
#
# $list mailing list with digest
#
$list:"|$homedir/wrapper resend -l $list -h $whereami $list-outgoing"
$list-digest:$list
$list-outgoing::include:$listdir/$list,
"| $homedir/wrapper digest -r -C -l $list-digest $list-digest-outgoing"
$list-digest-outgoing::include:$listdir/$list-digest
owner-$list-digest:owner-$list
owner-$list-digest-outgoing:owner-$list
$list-request: "|$homedir/wrapper request-answer $list"
$list-digest-request: "|$homedir/wrapper request-answer $list-digest"
owner-$list:$owner,
owner-$list-outgoing:owner-$list
$list-approval:$owner,
$list-digest-approval:$list-approval
END
$lista= <<"END";
#
# $list mailing list with archive
#
$list:"|$homedir/wrapper resend -l $list -h $whereami $list-outgoing"
$list-outgoing::include:$listdir/$list,
"| $homedir/wrapper archive2.pl -a -m -f $listdir/$list.archive/$list"
$list-request: "|$homedir/wrapper request-answer $list"
owner-$list:$owner,
owner-$list-outgoing:owner-$list
$list-approval:$owner
END
$listo= <<"END";
#
# $list mailing list
#
$list:"|$homedir/wrapper resend -l $list -h $whereami $list-outgoing"
$list-outgoing::include:$listdir/$list
$list-request: "|$homedir/wrapper request-answer $list"
owner-$list:$owner,
owner-$list-outgoing:owner-$list
$list-approval:$owner
END
}
Follow-Ups:
References:
|
|