Re: Monthly archiving of incoming mails

---------

From: Shane Wegner (shane@cm.nu)
Date: Mon Feb 19 2001 - 19:24:46 CST


On Tue, Feb 20, 2001 at 12:09:22AM +0100, Daniel Stenberg wrote:
> On Mon, 19 Feb 2001, Peter C. McCluskey wrote:
>
> > I suspect that a solution that builds on SmartList isn't going to be
> > quite as easy to install as an ideal solution would be.
>
> For the sake of discussion and comparison, I'll paste my tiny script that I
> pipe incoming mails into (using procmail to prevent simultaneous accesses).
>
> This works for low-volume lists. Use it at your own risk.

The problem I've found with something like this is there
is quite a bit of processing for each message which comes
in. I think an ideal solution would be for hypermail
itself to have outdir adjustable for per message. say:
OUTDIR public_html/listname-%y-%m
or some such thing. I believe it does that now but takes
the current date, not the date of the message it's
processing. I have an ugly perl script to do monthly
archiving I will post below. The advantage I find is
there's a lot less load on the machine for higher volume
lists, you just have procmail go out to lists/listname and
run list-archive.pl nightly.

#!/usr/bin/perl
#
# list-archive.pl
# Program for archiving mailing lists using Hypermail
# Written by Shane Wegner <shane@cm.nu>
# Last modified: 2000-03-07
#
use Getopt::Long;
# Required programs
$hypermail = "/usr/bin/hypermail";
$bzip2 = "/usr/bin/bzip2";
# Internal variables
($_,$_,$_,$_,$month,$year) = localtime;
$month++;
$year += 1900;
$month = "0$month" if (length($month) == 1);
$home = (getpwuid($<))[7];
&do_cmdline;
die("--list not specified.\n") if (!$listname);
if ($rearch && -e "$home/lists/$listname-$rearch.bz2")
{
# Re-archive a list for a particular month.
lsystem("rm -rf $home/public_html/lists/$listname-$rearch");
lsystem("$bzip2 -d -c $home/lists/$listname-$rearch.bz2 ".
"|$hypermail -c $home/lists/$listname.config ".
"-d $home/public_html/lists/$listname-$rearch -i") if (!$noarch);
} elsif ($nodate)
{
# standard mailing list with no monthly rotation.
lsystem("$hypermail -c $home/lists/$listname.config ".
"-d $home/public_html/lists/$listname -m $home/lists/$listname")
if (!$noarch);
} else {
if ( ! -d "$home/public_html/lists/$listname-$year-$month") {
# If the directly doesn't exist, it's probably a new month.
$month--;
if (!$month) {
$month = 12;
$year--;
} # endif
$month = "0$month" if (length($month) == 1);
lsystem("$hypermail -c $home/lists/$listname.config ".
"-d $home/public_html/lists/$listname-$year-$month -m $home/lists/$listname")
if (!$noarch);
rename("$home/lists/$listname","$home/lists/$listname-$year-$month");
lsystem("$bzip2 $home/lists/$listname-$year-$month");
$month++;
if ($month==13) {
$month = "01";
$year++;
} # endif
mkdir("$home/public_html/lists/$listname-$year-$month", 0711) ||
die "mkdir: $!\n";
} # endif
lsystem("$hypermail -c $home/lists/$listname.config ".
"-d $home/public_html/lists/$listname-$year-$month -m $home/lists/$listname")
if (!$noarch && -e "$home/lists/$listname");
}

sub do_cmdline {
local(%options);
Getopt::Long::config("pass_through", "no_ignore_case");
GetOptions(\%options,"list:s","rearch:s","nodate","noarch", "verbose");
foreach (keys(%options)) {
switch: {
/^list$/ && do {
$listname = $options{$_};
last switch;
}; /^rearch$/ && do {
$rearch = $options{$_};
last switch;
}; /^nodate$/ && do {
$nodate = 1;
last switch;
}; /^noarch$/ && do {
$noarch = 1;
last switch;
}; /^verbose$/ && do {
$verbose = 1;
last switch;
};
die("Invalid Option: $_\n");
} # end switch
} # end foreach
}

sub lsystem
{
print "system($_[0])\n" if ($verbose);
system $_[0];
}

-- 
Shane Wegner: shane@cm.nu
              http://www.cm.nu/~shane/
PGP:          1024D/FFE3035D
              A0ED DAC4 77EC D674 5487
              5B5C 4F89 9A4E FFE3 035D

---------

This archive was generated by hypermail 2.1.5.