[Patch] Proposal for maildir helper to use any subdirectories not just "a" to "z"
This proposed patch makes the maildir helper look in every subdirectory of the source directory for maildirs rather than just looking in the directories "a" through "z". This is helpful for the common method of setting up maildir schemas like below:
/var/maildir/domain.com/user1/
/var/maildir/domain.com/user2/
/var/maildir/anotherdomain.org/user1/
/var/maildir/anotherdomain.org/user2/
/var/maildir/anotherdomain.org/user3/
Patch here:
--- maildir.orig 2008-04-03 12:33:04.000000000 +0100 +++ maildir 2008-04-03 11:33:18.000000000 +0100 @@ -52,7 +52,6 @@ getconf destuser getconf multiconnection notset -letters="a b c d e f g h i j k l m n o p q r s t u v w x y z" failedcount=0 # strip trailing / destdir=${destdir%/} @@ -75,9 +74,9 @@ excludes="--exclude '.Trash/\*' --exclud function do_user() { local user=$1 local btype=$2 - local letter=${user:0:1} - local source="$srcdir/$letter/$user/" - local target="$destdir/$letter/$user/$btype.1" + local userdir=${3%/} + local source="$srcdir/$userdir/$user/" + local target="$destdir/$userdir/$user/$btype.1" if [ ! -d $source ]; then warning "maildir $source not found" return @@ -111,13 +110,15 @@ function do_remove() { local tmp2=@maketemp maildir-tmp-file@ ssh -p $destport $destuser@$desthost mkdir -p "$destdir/deleted" - for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do - ls -1 "$srcdir/$i/" | sort > $tmp1 - ssh -p $destport $destuser@$desthost ls -1 "$destdir/$i/" | sort > $tmp2 + cd "$srcdir" + for userdir in @ls -d1 */@; do + ls -1 "$srcdir/$userdir" | sort > $tmp1 + ssh -p $destport $destuser@$desthost ls -1 "$destdir/$userdir" | sort > $tmp2 for deluser in @join -v 2 $tmp1 $tmp2@; do [ "$deluser" != "" ] || continue - info "removing $destuser@$desthost:$destdir/$i/$deluser/" - ssh -p $destport $destuser@$desthost mv "$destdir/$i/$deluser/" "$destdir/deleted" + info "removing $destuser@$desthost:$destdir/$userdir$deluser/" + ssh -p $destport $destuser@$desthost mv "$destdir/$userdir$deluser/" "$destdir/deleted" done done rm $tmp1 @@ -127,8 +128,8 @@ function do_remove() { function do_rotate() { [ "$rotate" == "yes" ] || return; local user=$1 - local letter=${user:0:1} - local backuproot="$destdir/$letter/$user" + local userdir=${2%/} + local backuproot="$destdir/$userdir/$user" ( ssh -T -o [[PasswordAuthentication]]=no $desthost -l $destuser <(from redmine: created on 2008-04-03, closed on 2010-01-17)