[Dovecot] doveadm with multiple commands
This has been in my TODO for a while and today I implemented it (but didn't dare to test it yet :) So the problem has been that you want to run for example:
doveadm expunge -A mailbox Trash savedbefore 7d doveadm purge -A
This is annoying because it scans through the users' mailboxes twice, wasting disk IO and CPU. So how to make it do the scan only once? The syntax I thought of today would be:
doveadm multi [-A | -u wildcards] <separator string> <comand 1> [<separator string> <command 2> [...]]
So the first two commands could be for example:
doveadm multi -A : expunge mailbox Trash savedbefore 7d : purge
The ':' character is the separator. Any other string could be used as well, for example "?SEP?" or whatever.
Thoughts? Any better name for the command than "multi"?
Timo Sirainen wrote:
doveadm multi [-A | -u wildcards] <separator string> <comand 1> [<separator string> <command 2> [...]]
Thoughts?
Would be nice if this also worked through doveadm director proxy and executes the command sequence on the correct backend host for each user.
As command name I could also think of "doveadm sequence", which implies the commands being executed in serial order.
Regards Daniel
On 20.9.2012, at 22.17, Daniel Parthey wrote:
Timo Sirainen wrote:
doveadm multi [-A | -u wildcards] <separator string> <comand 1> [<separator string> <command 2> [...]]
Thoughts?
Would be nice if this also worked through doveadm director proxy and executes the command sequence on the correct backend host for each user.
Yes, it's going to.
As command name I could also think of "doveadm sequence", which implies the commands being executed in serial order.
Hmm. Maybe.
On 21.9.2012, at 8.28, Timo Sirainen wrote:
Timo Sirainen wrote:
doveadm multi [-A | -u wildcards] <separator string> <comand 1> [<separator string> <command 2> [...]]
Thoughts?
As command name I could also think of "doveadm sequence", which implies the commands being executed in serial order.
Hmm. Maybe.
"sequence" is already commonly used by IMAP protocol and Dovecot code to mean message sequence numbers. I think it would be too confusing to use that word for other things.
Timo Sirainen wrote:
On 21.9.2012, at 8.28, Timo Sirainen wrote:
Timo Sirainen wrote:
doveadm multi [-A | -u wildcards] <separator string> <comand 1> [<separator string> <command 2> [...]]
Thoughts?
As command name I could also think of "doveadm sequence", which implies the commands being executed in serial order.
Hmm. Maybe.
"sequence" is already commonly used by IMAP protocol and Dovecot code to mean message sequence numbers. I think it would be too confusing to use that word for other things.
Ok, so how about "batch"?
It reads a series of commands and collects them into one "batch job" which is then carried out.
http://en.wikipedia.org/wiki/Batch_(Unix)
Regards Daniel
On Mon, 2012-09-24 at 23:24 +0200, Daniel Parthey wrote:
Timo Sirainen wrote:
doveadm multi [-A | -u wildcards] <separator string> <comand 1> [<separator string> <command 2> [...]] .. Ok, so how about "batch"?
It reads a series of commands and collects them into one "batch job" which is then carried out.
Added this finally :) http://hg.dovecot.org/dovecot-2.1/rev/8cc28a5a3f4f
I was also considering using just another parameter to existing commands to specify the separator, but it was a bit more difficult to implement. Also I couldn't figure out any good parameter letter that wasn't already in use.
On 09/20/2012 06:01 PM, Timo Sirainen wrote:
Thoughts? Any better name for the command than "multi"?
How about 'execute' or 'exec'. -- Aleksander 'A.L.E.C' Machniak LAN Management System Developer [http://lms.org.pl] Roundcube Webmail Developer [http://roundcube.net] --------------------------------------------------- PGP: 19359DC1 @@ GG: 2275252 @@ WWW: http://alec.pl
On 21.9.2012, at 11.23, A.L.E.C wrote:
On 09/20/2012 06:01 PM, Timo Sirainen wrote:
Thoughts? Any better name for the command than "multi"?
How about 'execute' or 'exec'.
v2.1.10 already has "dovecot exec" that does a different thing. So can't be anything related to "exec"..
On 09/22/2012 06:50 PM, Timo Sirainen wrote:
On 21.9.2012, at 11.23, A.L.E.C wrote:
On 09/20/2012 06:01 PM, Timo Sirainen wrote:
Thoughts? Any better name for the command than "multi"?
How about 'execute' or 'exec'.
v2.1.10 already has "dovecot exec" that does a different thing. So can't be anything related to "exec"..
next is "run" or "pipe", but what if you create global separator option and detect multi-command syntax usage automatically without a keyword? Syntax for doveadm would be doveadm [-Dv] [-f formatter] [-s separator] [-A | -u wildcards ] command [command_options] [command_arguments] [separator command [command_options] [command_arguments] [...]] and example doveadm -A -s : expunge mailbox Trash savedbefore 7d : purge -- Aleksander 'A.L.E.C' Machniak LAN Management System Developer [http://lms.org.pl] Roundcube Webmail Developer [http://roundcube.net] --------------------------------------------------- PGP: 19359DC1 @@ GG: 2275252 @@ WWW: http://alec.pl
On 24.9.2012, at 14.44, A.L.E.C wrote:
next is "run" or "pipe", but what if you create global separator option and detect multi-command syntax usage automatically without a keyword?
Syntax for doveadm would be
doveadm [-Dv] [-f formatter] [-s separator] [-A | -u wildcards ] command [command_options] [command_arguments] [separator command [command_options] [command_arguments] [...]]
and example
doveadm -A -s : expunge mailbox Trash savedbefore 7d : purge
Hmm. Yes, that might work. Although it would have to be:
doveadm expunge -A -s : mailbox Trash savedbefore 7d : purge
because both -A and -s are mail command specific parameters, which won't work for non-mail commands.
Hmm. This reminds me also that it would be possible with some extra work to do some command interaction. IMAP supports saving search results, which can later be accessed with $ parameter. So this could be made to work:
doveadm search -s : from foo : fetch text \$ : expunge \$
At 2PM +0300 on 24/09/12 you (Timo Sirainen) wrote:
On 24.9.2012, at 14.44, A.L.E.C wrote:
next is "run" or "pipe", but what if you create global separator option and detect multi-command syntax usage automatically without a keyword?
Syntax for doveadm would be
doveadm [-Dv] [-f formatter] [-s separator] [-A | -u wildcards ] command [command_options] [command_arguments] [separator command [command_options] [command_arguments] [...]]
and example
doveadm -A -s : expunge mailbox Trash savedbefore 7d : purge
Hmm. Yes, that might work. Although it would have to be:
doveadm expunge -A -s : mailbox Trash savedbefore 7d : purge
because both -A and -s are mail command specific parameters, which won't work for non-mail commands.
Hmm. This reminds me also that it would be possible with some extra work to do some command interaction. IMAP supports saving search results, which can later be accessed with $ parameter. So this could be made to work:
doveadm search -s : from foo : fetch text \$ : expunge \$
This is turning into a proper scripting language, so perhaps something like
doveadm -e 'search from foo; fetch text $; expunge $'
with 'doveadm -F file' to run a script file?
Ben
On 21.9.2012, at 16.53, Steinar Bang wrote:
Timo Sirainen <tss@iki.fi>:
Thoughts?
How about: a) Dropping into a command prompt where it's possible to give commands? b) Making it possible to feed commands through a pipe (ie reading lines from stdin)?
Both of these would require adding some kind of new command parameter parsing. Currently shell does all the "multi word string" parsing and escaping and such. My original thought was also to be able to read commands from stdin, but I'd rather not add such special command parser, at least not yet..
participants (6)
-
A.L.E.C
-
Ben Morrow
-
Daniel Parthey
-
Michael Grimm
-
Steinar Bang
-
Timo Sirainen