[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debian-devel:13504] Re: How to read a lot of mails(Re: doc-debian-ja)



ä½é‡Žï¼ æµœæ¾ã§ã™ã€‚

In <20001228021020S.nabetani@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
  on "Thu, 28 Dec 2000 02:10:54 +0900',
   with "[debian-devel:13496] How to read a lot of mails(Re: doc-debian-ja)",
 NABETANI Hidenobu <nabetani@xxxxxxxxxxxxxxxxxxxxxxxxxxx> ã•ã‚“ wrote:

> kgh12351@xxxxxxxxxxx (Taketoshi Sano) writes:

> > ç§ã¯ procmail ã§æŒ¯ã‚Šåˆ†ã‘ãŸå¾Œã€ä¸»ã« t-gnus 㧠nnmh 使ã£ã¦èª­ã‚“ã§ã‚‹ã“ã¨ãŒ
> > 多ã„ã§ã™ã€‚ãŸã¾ã« mew ã‹ã‚‰èª­ã‚€æ™‚ã‚‚ã‚ã‚Šã¾ã™ãŒã€‚
> 
> ç§ã¯ procmail ã§æŒ¯ã‚Šåˆ†ã‘ãŸå¾Œã€mail2news(newsgate パッケージ) ã§
> local news server ã«æ”¾ã‚Šè¾¼ã‚“ã§ã„ã¾ã™ã€‚
> 
> 研究室等ã®è¤‡æ•°äººãŒèª­ã‚€å¯èƒ½æ€§ãŒã‚ã‚‹å ´åˆã«ã¯ä¾¿åˆ©ã§ã™ã€‚

ç§ã‚‚一部㮠ML ã«ã¤ã„ã¦ã¯ local ã® news group ã«æµã—ã¦ã¾ã™ã€‚

ç§ã®ä½¿ã£ã¦ã„ã‚‹ã®ã¯ JF ã®ã€ŒMail2News ミニãƒã‚¦ãƒ„ーã€v1.0, 4 November 1996ã€ã«
書ã‹ã‚Œã¦ã„ã‚‹ mail2news.pl をベースã«æ‰‹ã‚’加ãˆãŸã‚‚ã®ã§ã™ã€‚

例ãˆã° $HOME/.procmailrc ã«

:0 Hc
* ^List-name: nlug$
   LINUX/nlug-ml/.

   :0 A
   | /usr/local/lib/mail2news/fakefeed.sh linux-ml.nlug

ã¨æ›¸ã„ã¦ãŠã„㦠LINUX/nlug-ml/ 以下㫠mh å½¢å¼ã§ä¿å­˜ã™ã‚‹ã¨åŒæ™‚ã«
ローカルニュースグループ linux-ml.nlug ã«æµã™ã¨ã‹ã€‚

$ cat /usr/local/lib/mail2news/fakefeed.sh
#! /bin/sh
cat | /usr/local/lib/mail2news/fakeid.pl | \
  /usr/local/lib/mail2news/removegroup.pl | \
  /usr/local/lib/mail2news/mail2news.pl $1

$ cat /usr/local/lib/mail2news/removegroup.pl
#! /usr/bin/perl
# point at the correct location of perl

# header munging loop
while (<STDIN>) {
   last if /^$/;

   print 
   unless /^Newsgroups:/i;

}

print "\n";
print while <STDIN>;   # gobble rest of message

exit $?;

$ cat /usr/local/lib/mail2news/mail2news.pl
#! /usr/bin/perl
# point at the correct location of perl

($program = $0) =~ s%.*/%%;
# ( $version  ) = $] =~ /(\d+\.\d+).*\nPatch level/;
# die "$program: requires at least version 3 of perl\n"
#        if $version < 3;

# $inews = "/usr/bin/inews";
# $iopts = "-h -o \"mail2news gateway\"";
# $inews = "/bin/cat";
# $iopts = "";
$inews = "/usr/bin/inews";
$iopts = "-h -S ";
$postinghost = "localhost";

if ($#ARGV < 0) {
    $newsgroup = "local.m2n_test";
# we'll expect the newsgroup line in the body
} elsif ($#ARGV == 0) {
    $newsgroup = $ARGV[0];
} else {
    die "usage: $program [newsgroup]\n";
}

# in case inews dumps core or something crazy
$SIG{'PIPE'} = "plumber";
sub plumber { die "$program: \"$inews\" died prematurely!\n"; }

open (INEWS, "| $inews $iopts") ||
    die "$program: can't run $inews\n";

# header munging loop
$continuation = 0;

while (<STDIN>) {
   last if /^$/;

   # transform real from: line back to icky style
   # s/^From:\s+(.*) <(.*)>/From: $2 ($1)/;

   s/Message-Id/Message-ID/;

   if (/^\w+.*:/) {
     $continuation = 0; }

   if (/^(Date|Path|Newsgroups|Organization|Message-ID):/i) {
     print INEWS;
     $continuation = 0; }

   if (/^(Subject|From|References|Content-Type):/i) {
     $continuation = 1; }

   if (/^(MIME-.*|Content-Transfer-Encoding|X-.*):/i) {
     print INEWS;
     $continuation = 0; }

   if (/^(Reply-To|In-Reply-To):/i) {
     print INEWS;
     $continuation = 0; }

   if ($continuation == 1) {
     print INEWS; }

   $saw_subject |= ( $+ eq 'Subject' );

   $saw_msgid |= ( $+ eq 'Message-ID' );

   $saw_newsgroup |= ( $+ eq 'Newsgroups' );

   $saw_organization |= ( $+ eq 'Organization' );

   $saw_path |= ( $+ eq 'Path' );

}

   # transform from_ line to path header; also works locally
   s/^From\s+(\S+)@(\S+).*/Path: $2!$1/
     || s/^From\s+(\S+)[^@]*$/Path: $1\n/  unless $saw_path;

warn "$program: didn't expect Path in headers\n"
    if $saw_path;

warn "$program: didn't expect newsgroup in both headers and ARGV\n"
    if $newsgroup && $saw_newsgroup;

die "$program: didn't get newsgroup from either headers or ARGV\n"
    unless $newsgroup || $saw_newsgroup;

$approved = $newsgroup;
$approved =~ s/\./'-'/eg;

($sec,$min,$hour,$mday,$mon,$year)=localtime(time);
$madeupid =
  "\<$year$mon$mday.$hour$min$sec.$$\@m2n.pika.standalone.local.net\>";

printf INEWS "Newsgroups: %s\n", $newsgroup if $newsgroup && !$saw_newsgroup;
printf INEWS "Approved: %s\@localhost\n", $approved;
print INEWS "Subject: Untitled\n" unless $saw_subject;
printf INEWS "Message-ID: %s\n", $madeupid unless $saw_msgid;
# printf INEWS "NNTP-Posting-Host: %s\n", $postinghost;
print INEWS "Organization: (mail2news gateway)\n" unless $saw_organization;
# printf INEWS "Sender: %s\@localhost\n", $approved;
print INEWS "\n";

print INEWS while <STDIN>;   # gobble rest of message

close INEWS;
exit $?;


ã“ã‚“ãªæ„Ÿã˜ã€‚ML ã®ãƒ¡ãƒ¼ãƒ«ã‚’ローカルニュースグループã ã‘ã«æµã™ã‚ˆã†ã«ã™ã‚‹ã¨
 Expire ã¨ã‹ã¯ local news server ã«ã‚„らã›ã‚‹ã“ã¨ãŒã§ãã‚‹ã®ã§ä¾¿åˆ©ãªã‚“ã§ã™ãŒ
アナウンスã¨ã‹ã§è¤‡æ•°ã® ML ã«ã‚¯ãƒ­ã‚¹ãƒã‚¹ãƒˆã•ã‚ŒãŸãƒ¡ãƒ¼ãƒ«ã¯å„ ML ã§åˆ¥ã€…ã«å±Šã„ã¦
ã—ã¾ã†ã®ã§ã€å¾Œã‹ã‚‰æ¥ãŸãƒ¡ãƒ¼ãƒ«ã¯åŒã˜ Message-ID ã‚’æŒã¤ãŸã‚ã«å—ã‘å–ã£ã¦
もらãˆãªã„ã‚“ã§ã™ã‚ˆã­ã€‚

クロスãƒã‚¹ãƒˆã®å¤šã„ ML ã ã¨ãã®ã¸ã‚“ãŒå•é¡Œã«ãªã‚‹ã®ã§ã€ä¸€æ™‚期ã‘ã£ã“ã†
ローカルニュースグループã«é›†ã‚ã¦ã¾ã—ãŸãŒã€æœ€è¿‘㯠procmail ã«ã‚ˆã‚‹ MH å½¢å¼ã§ã®
ä¿å­˜ã¨ t-gnus ã® nnmh 経由ã§ã®é–²è¦§ã‚’組ã¿åˆã‚ã›ã¦ã¾ã™ã€‚

ãªãŠ expire ã¯è‡ªä½œã®ã‚¹ã‚¯ãƒªãƒ—トã§ã‚„ã£ã¦ã¾ã™ã€‚

$ cat ~/bin/purgeOLD
#! /bin/sh
#
# if you wish to check the action, enable next line
# TESTMODE=1
#
name=`basename $0`;
target="";
days=30;
if [ -z "$1" ] ; then
 echo " usage $name PATH DAYs ";
 exit -1;
else
 :
fi
#
# make assure that I am not at $HOME
/bin/mkdir $HOME/bin/.heaven 2>/dev/null
cd $HOME/bin/.heaven || exit 1
#
target=$1;
#
if [ ! -z "$target" ] ; then
  if [ ! -d "$target" ] ; then
    echo "Error on cd to $target!!";
    exit 1;
  fi
  cd "$target"
fi
#
if [ ! -z "$2" ] ; then
 days=$2;
fi
#
if [ ! -z "$3" ] ; then
  echo "test-mode"
  TESTMODE=1
fi
#
FILES=` /usr/bin/find . -daystart -follow -type f \
  -mtime +"$days" `
if [ -z "$FILES" ] ; then
  exit 0;
else
  :
fi
#
if [ ! -z "$target" ] ; then
 echo " -------------------------------- "
 echo "  Path: $target "
 echo "  Expire: $days"
fi
echo " Following files will be deleted : ";
echo "$FILES" | column -x
if [ -z "$TESTMODE" ] ; then
  echo "$FILES"|xargs rm 
#
# /usr/bin/find . \
#  -daystart -follow -type f \
#  -mtime +"$days" |xargs rm -f
#
  echo ""
fi

ã“れを次ã®ã‚¹ã‚¯ãƒªãƒ—トã‹ã‚‰å‘¼ã³å‡ºã—ã¦ã¾ã™ã€‚

$ cat ~/bin/purgeMails
#! /bin/sh
LOG=$HOME/log/purgemail.log
PURGE=$HOME/bin/purgeOLD
FIND=/usr/bin/find
SED=/bin/sed
MHFOLDER=/usr/bin/mh/folder
MHSORTM=/usr/bin/mh/sortm
# echo is a shell built-in
XARGS=/usr/bin/xargs
RM=/bin/rm

function do_purge()
{
	TARGET=$1
	DAYS=$2
	if [ -z "$TARGET" ] ; then return -1; fi
	if [ -z "$DAYS" ] ; then return -1; fi
	if [ ! -d "$TARGET" ] ; then
		  echo "Error : requested directory is not valid";
		  echo "Check : $TARGET";
		  return -1;
	fi
	cd $1 || return -1
	FILES=` /usr/bin/find . -daystart -follow -type f -mtime +"$DAYS" `
	if [ -z "$FILES" ] ; then
		  return 0;
	else
		  $FIND $TARGET -follow -name '.mew-cache'|$XARGS $RM -f
		  $FIND $TARGET -follow -name '.mh_sequences'|$XARGS $RM -f
		  $PURGE $TARGET $DAYS >>"$LOG"

#		  for i in `$FIND "$TARGET" -type d -follow -mindepth 1`;
#		    do
#			NAM=`echo "$i"|$SED -e "s,^$HOME/Mail/,+,"`
#			$MHFOLDER -pack "$NAM" >>"$LOG"
#			$MHSORTM "$NAM" >>"$LOG"
#		    done
	fi

}

if [ -f $LOG -a -s $LOG ] ; then
    /usr/bin/savelog -p -t $LOG;
fi

/usr/bin/touch $LOG >&/dev/null
/bin/echo "begin: `/bin/date`" >>"$LOG"
:
do_purge $HOME/Mail/purge/years5/  2000
do_purge $HOME/Mail/purge/years3/  1200
do_purge $HOME/Mail/purge/yearly/   400
do_purge $HOME/Mail/purge/months6/  200
do_purge $HOME/Mail/purge/months3/  100
do_purge $HOME/Mail/purge/months2/   70
do_purge $HOME/Mail/purge/monthly/   33
do_purge $HOME/Mail/purge/weeks2/  16
do_purge $HOME/Mail/purge/weekly/   9
do_purge $HOME/Mail/purge/3days/   5
do_purge $HOME/Mail/purge/daily/   3

/bin/echo "end: `/bin/date`" >>"$LOG"

/usr/bin/mail -s "purgemail.log" sano <$LOG


ã“ã® purgeMails 㯠crontab ã«

# weekly purge of mail
30 12 * * 5 $HOME/bin/purgeMails

ã¨ã—ã¦ç™»éŒ²ã—ã¦ã‚ã‚Šã€é€±ã«ä¸€åº¦ã€é‡‘曜日ã®æ˜¼ã«è‡ªå‹•ã§å®Ÿè¡Œã•ã‚Œã¾ã™ã€‚

メールを振り分ã‘るディレクトリ㯠$HOME/Mail 以下ã«ã‚ã‚‹ã‚“ã§ã™ãŒã€
 $HOME/Mail/purge/<expire_duration>/ 以下ã«ãã‚Œãžã‚Œã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¸ã®
シンボリックリンクを置ã„ã¦ã€<expire_duration> ã«ç›¸å½“ã™ã‚‹æ—¥æ•°ã§
 expire ã•ã‚Œã¾ã™ã€‚

一度失敗ã—㦠$HOME 㧠rm -rf を始ã‚ã¦ã—ã¾ã£ãŸã“ã¨ãŒã‚ã‚Šã¾ã™ãŒã€
ãã®å¾Œæ”¹è‰¯ã—ãŸã®ã§ãŸã¶ã‚“今ã¯å¤§ä¸ˆå¤«ãªã¯ãšã€‚

-- 
     # (ã‚ãŸã—ã®ãŠã†ã¡ã¯æµœæ¾å¸‚ã€ã€Œå¤œã®ãŠè“å­ã€ã§æœ‰åã•ã€‚)
    <kgh12351@xxxxxxxxxxx> : Taketoshi Sano (ä½é‡Žã€€æ­¦ä¿Š)