Re: [Dovecot] Maildirmake equiv?

2013-08-19 Thread Charles Marcus

On 2013-08-18 8:24 PM, LuKreme  wrote:

Yep. seems to work fine. I think courier had a special command because it 
creates some extra files and a directory inside the maildir for its indexing.


Courier doesn't use indexing.

--

Best regards,

*/Charles/*


Re: [Dovecot] Maildirmake equiv?

2013-08-18 Thread LuKreme

On 16 Aug 2013, at 17:44 , David Benfell  wrote:

> mkdir ${path}/${name}/tmp
> mkdir ${path}/${name}/cur
> mkdir ${path}/${name}/new
> 
> Where ${path} is the path to the parent folder and ${name} is the name
> of the Maildir.
> 
> That's really all there is to it.

$ cat ~/bin/maildirmake
#!/bin/bash

mkdir -p $1/{new,cur,tmp}

$ ~/maildirmake .test && ls -lsR .test
total 24
8 drwxr-xr-x  2 kremels  kremels  512 Aug 18 18:23 cur
8 drwxr-xr-x  2 kremels  kremels  512 Aug 18 18:23 new
8 drwxr-xr-x  2 kremels  kremels  512 Aug 18 18:23 tmp

.test/cur:
total 0

.test/new:
total 0

.test/tmp:
total 0

Yep. seems to work fine. I think courier had a special command because it 
creates some extra files and a directory inside the maildir for its indexing.

-- 
Why can't you be in a good mood? How hard is it to decide to be in a
good mood and be in a good mood once in a while?"



Re: [Dovecot] Maildirmake equiv?

2013-08-16 Thread David Benfell
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 08/15/2013 11:14 PM, Steffen Kaiser wrote:
> On Thu, 15 Aug 2013, LuKreme wrote:
> 
>> Since I am using dovecot I do not have courier installed, but
>> Courier had a very handy tool for making maildir folders called
>> `maildirmake` which I used in some automated backup scripts. How
>> do I duplicate maildirmake in dovecot?
> 
> To replace the inner find, you could look at doveadm move -u 
> savedbefore ...
> 
> To replace maildirmake -f, look at doveadm mailbox create -u
> 
> 
> But you seem to create a new Maildir with each invokation of $MDM
> (no -f option). IMHO it seems to be easier to make a small script,
> that creates new/cur/tmp and, if not INBOX, touches maildirfolder.
> 
> Kind regards,
> 
> -- Steffen Kaiser

The generic formula for creating Maildirs is:

mkdir ${path}/${name}/tmp
mkdir ${path}/${name}/cur
mkdir ${path}/${name}/new

Where ${path} is the path to the parent folder and ${name} is the name
of the Maildir.

That's really all there is to it.

- -- 
David Benfell / benf...@parts-unknown.org
Please see https://parts-unknown.org/node/2 for GnuPG information (or
the attachment you don't understand)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.20 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSDrlHAAoJEKrN0Ha7pkCOthMP/1PyGW9Kidyzoc7bTbLunF19
ZRQeRcGj42w1BXP1NI3+yx52hlhC6OxOuhZiBa3OfzK67I1Ww4lLa2Q4MMbC7M+O
8xS2VKgRTzAD61IY0hlnInPV/+gn6AYWnRIPiH87Q7ru6r9+XudS/6cKpnybqK2i
rDAr2v/crFEz772QIJ0WVycNMABOfDi+9QyHQDii6Rnhvwq1rR21A3ZkJFdN5hK+
ZOVgin8UK0Zx3y9nLE8tmdChp3NU6v1IcX2XdqnaQKvGIKoTP34dsKd2c5Cjt0fI
npKncTdkwmZFSbovHssn9LGfsEiDBbES5gXMxfpYTtDmCoGhQtT62rll8nBH+l8f
H2G6MFZzyRxVALO9TksKztyCOMBDohABK8+nXrJQuqV+W8+MgBN77wB56NsQQRoo
ajH9OKJfbHGmCXyMinKHFMD0VMOICHYummWO5mPQIeE/YMk/+3GyjQ9iblnGu7Ma
mU1k5hvh79vYB0eUEiGx4fcHB8BsC38H+DCI9eN8oLMz9W6cds3hgxiTNiIyXuFF
7WmSMrZjO2ozlXr581uQVIp7YEGBf9kJglzil9lIRlyYKEAthlQ8JH8BBUmICvz7
XB3Za+Cmaby9/binwqIdBget8MMu/wsFBtSTA6JuB2a/kYCn7P3S+jVj+xzbbh4f
gpDhHczhIWFA0OS8AkLP
=jIft
-END PGP SIGNATURE-
<>

Re: [Dovecot] Maildirmake equiv?

2013-08-16 Thread Thomas Leuxner
* LuKreme  2013.08.16 20:15:

> MDM is only invoked if the target folder doesn't exist. For example, for this 
> list the current target folder is .zz.dovecot.2013. Next year, it will change 
> to .zz.dovecot.2014
> 
> (the .zz is because iOS mail does't support unsubscribing from mailboxes and 
> doesn't let you collapse folders, so the zz puts these archive folders way at 
> the end.)

Here's a script I wrote to archive old mail using doveadm. It should be simple 
enough to tweak it to your needs. Basically you call it with a mailbox name and 
it will archive all mails before a certain date. Source and Destination Path 
are in the script code:

dovearchive.sh:
#!/bin/bash
# Archive old posts before certain date to 'Public/Archive/Mailbox/Year' 
# Set basic parameters accordingly:
# archive=2011, before_date=$year-mm-dd
# source_mailbox_base=Public/Newsletters
# dest_mailbox_base=Public/Archive/Newsletters
# Actual Mailbox is read from command line
set -e
archive=2012
let year=$archive+1
before_date=$year-01-01
mailbox_owner=t...@leuxner.net
source_mailbox_base='Public/Newsletters'
dest_mailbox_base='Public/Archive/Newsletters'
#acl_admin_group=owner
acl_admin_group='group=PublicMailboxAdmins'
acl_unlock_seq="$acl_admin_group delete expunge insert lookup post read write 
write-seen write-deleted"
acl_lock_seq="$acl_admin_group insert lookup post read write write-seen"
acl_lock_archive="$acl_admin_group insert lookup read write write-seen"

msg_formatted() {
  echo "$(date "+%b %d %H:%M:%S") $*"
}

if [ $# -eq 0 ]; then
echo "usage: $0 mailbox" >&2
exit 1
fi

# Mailbox exists?
doveadm acl get -u $mailbox_owner "$source_mailbox_base/$1" || { echo 'Mailbox 
not found.'; exit 1; }

# Create New Archive Mailbox
doveadm mailbox create -u $mailbox_owner "$dest_mailbox_base/$1/$archive"

# Modify ACL, expunge mail and revert ACL
msg_formatted "[>] Archiving \"$dest_mailbox_base/$1/$archive\""

doveadm acl set -u $mailbox_owner "$source_mailbox_base/$1" $acl_unlock_seq
doveadm move -u $mailbox_owner "$dest_mailbox_base/$1/$archive" mailbox 
"$source_mailbox_base/$1" before $before_date
doveadm acl set -u $mailbox_owner "$source_mailbox_base/$1" $acl_lock_seq
doveadm acl set -u $mailbox_owner "$dest_mailbox_base/$1/$archive" 
$acl_lock_archive

msg_formatted '[ Complete ]'


signature.asc
Description: Digital signature


Re: [Dovecot] Maildirmake equiv?

2013-08-16 Thread LuKreme

On 16 Aug 2013, at 05:04 , Duane Hill  wrote:

> On Friday, August 16, 2013 at 6:39:23 AM UTC, li...@sterenborg.info 
> confabulated:
> 
>> On 08/16/2013 06:53 AM, LuKreme wrote:
>>> Since I am using dovecot I do not have courier installed, but Courier had a 
>>> very handy
>>> tool for making maildir folders called `maildirmake` which I used in some 
>>> automated
>>> backup scripts. How do I duplicate maildirmake in dovecot?
> 
>> Dovecot can autocreate mailboxes. Is that something you can use?
> 
>> http://wiki2.dovecot.org/MailboxSettings

I don't think so.

> Keeping  in  mind, the mailboxes are created on disk upon first access
> (i.e.  message  is transferred to the mailbox via sieve or the mailbox
> is accessed via IMAP).

And that's why. I might be able to use sieve sometime in the future once I 
figure out what it can do, but right now I have a script that works and simply 
want to modify it for dovecot.


-- 
Of course, there were various groups seeking his overthrow, and this was
right and proper and the sign of a vigorous and healthy society. No-one
could call him unreasonable about the matter. Why, hadn't he founded
most of them himself? And what was so beautiful was the way they spent
nearly all their time bickering with one another.  Human nature, the
Patrician always said, was a marvelous thing. Once you understood where
its levers were. --Guards! Guards!



Re: [Dovecot] Maildirmake equiv?

2013-08-16 Thread LuKreme

On 16 Aug 2013, at 00:14 , Steffen Kaiser  wrote:

> To replace the inner find, you could look at
> doveadm move -u  savedbefore ...
> 
> To replace maildirmake -f, look at
> doveadm mailbox create -u 

Thanks. If the script is running as the user, does doveadm still need the -u 
flag?

> But you seem to create a new Maildir with each invokation of $MDM (no -f 
> option). IMHO it seems to be easier to make a small script, that creates 
> new/cur/tmp and, if not INBOX, touches maildirfolder.

MDM is only invoked if the target folder doesn't exist. For example, for this 
list the current target folder is .zz.dovecot.2013. Next year, it will change 
to .zz.dovecot.2014

(the .zz is because iOS mail does't support unsubscribing from mailboxes and 
doesn't let you collapse folders, so the zz puts these archive folders way at 
the end.)

-- 
I've got a sonic screwdriver!
Yeah? I've got a chair!
...
Chairs *are* useful.



Re: [Dovecot] Maildirmake equiv?

2013-08-16 Thread Duane Hill
On Friday, August 16, 2013 at 6:39:23 AM UTC, li...@sterenborg.info 
confabulated:

> On 08/16/2013 06:53 AM, LuKreme wrote:
>> Since I am using dovecot I do not have courier installed, but Courier had a 
>> very handy
>> tool for making maildir folders called `maildirmake` which I used in some 
>> automated
>> backup scripts. How do I duplicate maildirmake in dovecot?

> Dovecot can autocreate mailboxes. Is that something you can use?

> http://wiki2.dovecot.org/MailboxSettings

Keeping  in  mind, the mailboxes are created on disk upon first access
(i.e.  message  is transferred to the mailbox via sieve or the mailbox
is accessed via IMAP).

-- 
If at first you don't succeed...
...so much for skydiving.



Re: [Dovecot] Maildirmake equiv?

2013-08-15 Thread Rob Sterenborg (lists)

On 08/16/2013 06:53 AM, LuKreme wrote:

Since I am using dovecot I do not have courier installed, but Courier had a 
very handy
tool for making maildir folders called `maildirmake` which I used in some 
automated
backup scripts. How do I duplicate maildirmake in dovecot?


Dovecot can autocreate mailboxes. Is that something you can use?

http://wiki2.dovecot.org/MailboxSettings

http://dovecot.2317879.n4.nabble.com/dovecot-2-2-Warning-autocreate-plugin-is-deprecated-use-mailbox-auto-setting-instead-td41673.html


--
Rob



Re: [Dovecot] Maildirmake equiv?

2013-08-15 Thread Steffen Kaiser

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thu, 15 Aug 2013, LuKreme wrote:

Since I am using dovecot I do not have courier installed, but Courier 
had a very handy tool for making maildir folders called `maildirmake` 
which I used in some automated backup scripts. How do I duplicate 
maildirmake in dovecot?


To replace the inner find, you could look at
doveadm move -u  savedbefore ...

To replace maildirmake -f, look at
doveadm mailbox create -u 

But you seem to create a new Maildir with each invokation of $MDM (no -f 
option). IMHO it seems to be easier to make a small script, that creates 
new/cur/tmp and, if not INBOX, touches maildirfolder.


Kind regards,

- -- 
Steffen Kaiser

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)

iQEVAwUBUg3DSV3r2wJMiz2NAQJWqQf6AhVbFjyIT5wMwdT6liGI/5NI1K81c5qM
N7p0kfvivCgaDM0is8DiL+eKINsL76Bk07iJfAMiRuNuIb2cAcOgJwNCEIjVtwEN
7bSvX66NmO0Fzjob5SmbBe6LNtMylpEMa7vPdQGeuN+Jm+Btx7btsuAN+wvekJ+2
NwhR+rxt0fm6wT8+jtuUkyg05FzneL5pUEt/+P+KjBdNeJ82tCwD7AFyrWICKajT
br6vTS2AA9/jqh9P1dHtYg6ztkaRtqGbX5YKewmaqJQ3eu+NUo1wO0sxaRtaKdfj
/hjiOs9KPpmq8iRYiKPMiihOXjoI2wVGI4HuG7j0Wv93kBhCkfFgsg==
=TLXx
-END PGP SIGNATURE-


[Dovecot] Maildirmake equiv?

2013-08-15 Thread LuKreme
Since I am using dovecot I do not have courier installed, but Courier had a 
very handy tool for making maildir folders called `maildirmake` which I used in 
some automated backup scripts. How do I duplicate maildirmake in dovecot?

for example:

#!/bin/bash
# v1.2a Testing for new dovecot install

# Archive mail from folders without [0-9]{4} Maildirs
# after they are 21 days old to a yearly folder

MDIR="$HOME/Maildir"
MDM="/usr/local/bin/maildirmake"
YEAR=`/usr/local/bin/gdate -d "last month" '+%Y'`
echo "The Year is $YEAR..."

OIFS=$IFS
IFS="
"

for I in `find $MDIR -maxdepth 1 -mindepth 1 -type d| egrep -v 
"[0-9][0-9][0-9][0-9]"`; do
  MYDIR="${I}"
  TBASE=`basename $MYDIR`
  # if [ ! $TBASE == "Maildir" ]; then
TDIR=`dirname $MYDIR`
TARGET="${TDIR}/.zz${TBASE}.${YEAR}"
# echo "$MYDIR $TARGET"
if [ -d "$MYDIR/cur" ]; then
  echo -n "Processing ${MYDIR} => ${TARGET}..."
  if [ ! -d "${TARGET}" ]; then
echo ""
echo -n "WARNING ${TARGET} does not exist. invoking $MDM ${TARGET}..."
$MDM "${TARGET}"
  fi
  if [ -d "${TARGET}" ]; then
# echo "$TARGET does exist, moving files"
find ${MYDIR}/cur -type f -ctime +21 -exec mv {} ${TARGET}/cur/ \;
echo "done."
  else
echo "$TARGET does not exist"
  fi
fi
  # fi
done

IFS=$OIFS

-- 
Forever was over. All the sands had fallen. The great race between
entropy and energy had been run, and the favourite had been the winner
after all.  Perhaps he ought to sharpen the blade again?  No.  Not much
point, really.