ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Michael Shigorin <mike@osdn.org.ua>
To: ALT Linux Sisyphus discussion list <sisyphus@altlinux.ru>
Subject: [sisyphus] mailrotate
Date: Mon, 4 Jul 2005 19:48:52 +0300
Message-ID: <20050704164852.GA24580@osdn.org.ua> (raw)
In-Reply-To: <42C56B4A.2000505@altlinux.org>


[-- Attachment #1.1: Type: text/plain, Size: 661 bytes --]

On Fri, Jul 01, 2005 at 08:11:54PM +0400, Mikhail Yakshin wrote:
> >>А не знаю, у меня локальная в основном.  Можно подумать и над
> >>IMAP, вот только мне не требуется пока.
> >Да да, интересно как ты на Imap сделаешь rotate.

Женю натравлю. :)

> Я делаю примерно так %) Написано за пару минут, works-for-me...

Эээ... фигня-с, моя бодяга хотя бы недельный контекст оставляет.
;-)

Опубликована она была ещё в 2001:
http://lists.altlinux.ru/pipermail/community/2001-October/030262.html

Аттачу, понравится -- могу на freesource плюхнуть :-)

-- 
 ---- WBR, Michael Shigorin <mike@altlinux.ru>
  ------ Linux.Kiev http://www.linux.kiev.ua/

[-- Attachment #1.2: mailrotate.sh --]
[-- Type: text/plain, Size: 2045 bytes --]

#!/bin/sh
# A free script to rotate mail by Michael Shigorin <mike@altlinux.ru>
# v20011020

# moves $MBOXES (wildcards allowed) in $MAIL to files named after $DATEFMT in
# directories under $ARCROOT, leaving fresher than $KEEP (see also $SINCEAFTER)
# not to leave mailboxes empty.

# WARNING: BACKUP YOUR MAIL BEFORE USING! NO WARRANTIES!

MDIR="$HOME/mail"
ARCROOT="$MDIR/archive"
MBOXES="_* READ MDS"
LOG="$ARCROOT/mailrotate.log"
KEEP="7 days"	# to leave me in context
KEEPEMPTY=	# keep empty boxes? "" or non-empty string
SKIPEXIST=	# skip existing archive mbox or append to it?
MODE=644	# mktemp will 
DATEFMT="%Y-%m-%d"
SINCEAFTER=after	# ...or "since". One day difference.
MAILPS="mutt"	# egrep's regexp, i.e. (mutt|pine|sylpheed)

echo `date +$DATEFMT` >>$LOG
[ -n "`ps -u $USER | egrep " $MAILPS$"`" ] && {
	echo "$MAILPS running as $USER, exiting..." >>$LOG
	exit
} || echo "$0: starting..." >>$LOG

perl -e 'require Date::Parse; require Date::Manip' || {
	echo "ERROR: grepmail needs Date::Parse and Date::Manip to" >&2
	echo "       enable -d option (which we need)." >&2
	echo >&2
	echo "Exiting to keep your mail safe; please run" >&2
	echo "perl -MCPAN -e 'install Date::Parse' && perl -MCPAN -e 'install Date::Manip'" >&2
	echo "as root to install the needed modules!" >&2
	exit 1
}

cd "$MDIR"
for i in $MBOXES; do
	[ ! -f "$i" -o -f "$i.lock" ] && continue
	ARCDIR="$ARCROOT/$i"
	[ -d "$ARCDIR" ] || mkdir -p "$ARCDIR"
	ARCMBOX="$ARCDIR/`date -d "$KEEP ago" +$DATEFMT`"
	[ -f "$ARCMBOX" -a "$SKIPEXIST" ] && continue
	TMPFILE="`mktemp "$i.tmp-XXXXXX"`"
	grepmail -had "$SINCEAFTER $KEEP ago" "$i" >"$TMPFILE" 2>>$LOG
#	[ -f "$ARCMBOX" ] && echo "WARNING: $ARCMBOX already exists!" >>$LOG
	grepmail -vhad "$SINCEAFTER $KEEP ago" "$i" >>"$ARCMBOX" 2>>$LOG
	[ -s "$TMPFILE" -o "$KEEPEMPTY" ] && {
		mv "$TMPFILE" "$i"
		chmod $MODE "$i"
	}
	[ -s "$ARCMBOX" -o "$KEEPEMPTY" ] || rm -f "$ARCMBOX"
done

find "$MDIR/" -name '*.tmp-*' | xargs rm -rf
echo "$0: done." >>$LOG

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-07-04 16:48 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-30  7:22 [sisyphus] gmane.org - удобное чтение рассылок Anton Farygin
2005-06-30  9:21 ` Alexey Morsov
2005-06-30  9:43   ` [sisyphus] " Anton Farygin
2005-06-30 10:11     ` Alexey Morsov
2005-06-30 10:40     ` Mikhail Yakshin
2005-06-30 10:55       ` [sisyphus] " Anton Farygin
2005-07-01 16:11     ` [sisyphus] " Mikhail Yakshin
2005-06-30 10:26 ` [sisyphus] " Alexey Morsov
2005-06-30 10:34   ` [sisyphus] " Anton Farygin
2005-06-30 11:10     ` Alexey Morsov
2005-06-30 12:32       ` Alexei Takaseev
2005-06-30 12:32       ` Anton Farygin
2005-06-30 11:11     ` Alexei Takaseev
2005-06-30 11:20       ` [sisyphus] " Anton Farygin
2005-06-30 11:33         ` Alexei Takaseev
2005-07-04 16:38     ` [sisyphus] " Arioch
2005-07-05  5:24       ` Vasya Makarov
2005-07-05  5:45         ` [sisyphus] " Anton Farygin
2005-07-05 14:51           ` Andrey Rahmatullin
2005-06-30 10:38   ` [sisyphus] " Alexei Takaseev
2005-06-30 10:43   ` Mike Lykov
2005-06-30 10:59     ` Re[2]: " Anton Gorlov aka stalker
2005-06-30 11:08       ` Alexey Morsov
2005-06-30 11:09         ` [sisyphus] " Michael Isachenkov
2005-06-30 12:10           ` Alexey Morsov
2005-06-30 12:16             ` Michael Isachenkov
2005-06-30 12:11           ` Michael Isachenkov
2005-06-30 12:20             ` Alexey Morsov
2005-06-30 12:28               ` Michael Isachenkov
2005-07-01  6:37                 ` iLL
2005-07-04 16:38                 ` [sisyphus] " Arioch
2005-06-30 11:34         ` [sisyphus] " Alexei Takaseev
2005-06-30 11:56           ` [sisyphus] " Alexey Morsov
2005-06-30 12:35             ` Alexei Takaseev
2005-06-30 12:49               ` [sisyphus] " Anton Farygin
2005-06-30 13:27                 ` Alexey Rusakov
2005-06-30 13:29                   ` [sisyphus] " Anton Farygin
2005-06-30 13:48                     ` Alexey I. Froloff
2005-06-30 13:52                       ` [sisyphus] [OT] " Michael Shigorin
2005-06-30 13:48                 ` [sisyphus] " Michael Shigorin
2005-06-30 13:49                   ` Alexey Morsov
2005-06-30 13:53                     ` [sisyphus] [OT] " Michael Shigorin
2005-06-30 13:54                       ` [sisyphus] " Anton Farygin
2005-06-30 14:57                         ` Eugene Ostapets
2005-06-30 15:22                           ` Alexey Morsov
2005-07-01 16:11                         ` Mikhail Yakshin
2005-07-04 16:48                           ` Michael Shigorin [this message]
2005-06-30 14:03                     ` [sisyphus] " Eugene Ostapets
2005-06-30 15:23                       ` Alexey Morsov
2005-06-30 18:29                         ` Eugene Ostapets
2005-06-30 13:52                   ` Anton Farygin
2005-07-04 16:45                     ` [sisyphus] ротирование/индексирование почты Michael Shigorin
2005-06-30 12:49               ` [sisyphus] Re: gmane.org - удобное чтение рассылок Alexey Morsov
2005-06-30 12:29           ` Anton Farygin
2005-06-30 11:29 ` [sisyphus] " Michael Isachenkov
2005-06-30 11:35   ` [sisyphus] " Alexey Morsov
2005-06-30 11:42     ` Michael Isachenkov
2005-06-30 11:57       ` Alexey Morsov
2005-06-30 12:28       ` [sisyphus] " Anton Farygin
2005-06-30 12:33         ` Michael Isachenkov
2005-07-02 11:10     ` [sisyphus] " Sergey V Turchin
2005-06-30 11:41   ` Alexey Morsov
2005-06-30 12:37   ` [sisyphus] " Alexei Takaseev
2005-07-01 13:42 ` [sisyphus] [JT] " Afanasov Dmitry
2005-07-02  8:07     ` Afanasov Dmitry
2005-07-02  9:03       ` Re[2]: " php-coder
2005-07-04 14:21         ` [sisyphus] [JT] mutt - удобное чтение рассылок :) Afanasov Dmitry
2005-07-04 16:43           ` [sisyphus] " Michael Shigorin
2005-07-04  8:04       ` [sisyphus] [JT] gmane.org - удобное чтение рассылок Mike Lykov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050704164852.GA24580@osdn.org.ua \
    --to=mike@osdn.org.ua \
    --cc=sisyphus@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git