From: x2000habouzit Date: Tue, 30 Nov 2004 10:58:29 +0000 (+0000) Subject: the miracuous script. X-Git-Tag: xorg/old~750 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=954d3d03d2575b11581a2ad643ec2a3761ab6a89;p=platal.git the miracuous script. how it works ? mhonarc_by_month.pl path_to_platal.mrc name_of_the_list mbox1 [mbox2 [mbox3 ...]] path_to_platal.mrc is the path to platal.mrc name_of_the_list is for example polytechnique.org-br (HAS TO BE LOWERCASE) mboxes are UNGZIPPED mboxes, in any order this script ADDS mails to the archive, so you can give to him mboxes one by one if you want. for example : mhonarc_by_month.pl ./my.mrc polytechnique.org-foo foo.mbox.stamp1 mhonarc_by_month.pl ./my.mrc polytechnique.org-foo foo.mbox.stamp2 is equivalent to : mhonarc_by_month.pl ./my.mrc polytechnique.org-foo foo.mbox.stamp1 foo.mbox.stamp2 it adds the archive in /var/spool/platal/archives/ moreover, /var/spool/platal/archives/attachments/ MUST exists, other directories are created on the fly. /var/spool/platal/archives/ can obviously be a symlink --- diff --git a/scripts/mailman/mhonarc_by_month.pl b/scripts/mailman/mhonarc_by_month.pl new file mode 100755 index 0000000..efbbefb --- /dev/null +++ b/scripts/mailman/mhonarc_by_month.pl @@ -0,0 +1,56 @@ +#! /bin/perl -w +# +use strict; + +my $rcfile = shift; +my $list = shift; +my $spool = "/var/spool/platal/archives/"; +my $tmpbox = "mytmpbox.mbox"; + +my %conv; +$conv{'Jan'} = "01"; +$conv{'Feb'} = "02"; +$conv{'Mar'} = "03"; +$conv{'Apr'} = "04"; +$conv{'May'} = "05"; +$conv{'Jun'} = "06"; +$conv{'Jul'} = "07"; +$conv{'Aug'} = "08"; +$conv{'Sep'} = "09"; +$conv{'Oct'} = "10"; +$conv{'Nov'} = "11"; +$conv{'Dec'} = "12"; + +my $mail = ""; +my $line = ""; +my $odir = ""; + +my $y = ''; +my $m = ''; + + +while(<>) { + $line = $_; + if($line =~ /^From +[^@ ]*@[^@ ]* +[a-z]* +([a-z]*) +\d* +\d*:\d*:\d* +(\d*)$/i) { + if ($conv{$1} ne $m || $y ne $2) { + if($odir) { + close FILE; + $odir = $spool.$list."/$y/$m"; + system("mkdir -p $odir") unless (-d $odir); + system("mhonarc -add -outdir $odir -rcfile $rcfile $tmpbox"); + } else { + $odir = 1; + } + + $m = $conv{$1}; + $y = $2; + open FILE,"> $tmpbox"; + } + } + print FILE $line; +} + +if($odir) { + close FILE; + unlink $tmpbox; +}