If I recall there is a tab at the end of the line, too. Did someone already answer this, and I just missed it!? Sorry it took me so long... Just too busy to read the list everyday (or even every week) Merry Christmas! c* ----- Original Message ----- From: "Joe Hrbek" <[EMAIL PROTECTED]> To: "Info-Cyrus" <[EMAIL PROTECTED]> Sent: Friday, December 12, 2003 11:49 AM Subject: ctl_mboxlist -u ?
> Hi everyone! > > I'm trying to write a bash script (just out of curiosity) that will harvest > usernames from the cyrus spool directory and then write the output to a file > in a similar manner that ctl_mboxlist -d would. Below are my results thus > far. Aside from the formatting, I see no difference in the output, however, > when I try to do a ctl_mboxlist -u on the file I generated it bails on each > line with an error: no partition found. (see below) > > Result from ctl_mboxlist -d > newmail: > user.bkieffer^foo^com default bkieffer.foo.com lrswipcda > cyrus lrswipcda > user.bloberg^foo^com default bloberg.foo.com lrswipcda > cyrus lrswipcda > user.bpruett^foo^com default bpruett.foo.com lrswipcda > cyrus lrswipcda > user.bspringer^foo^com default bspringer.foo.com lrswipcda > cyrus lrswipcda > > Result from a bash script that harvests directory names: > user.bboggess^foo^com default bboggess.foo.com lrswipcda cyrus lrswipcda > user.bdaniel^foo^com default bdaniel.foo.com lrswipcda cyrus lrswipcda > user.bfleming^foo^com default bfleming.foo.com lrswipcda cyrus lrswipcda > user.bgordon^foo^com default bgordon.foo.com lrswipcda cyrus lrswipcda > And my error after I run ctl_mboxlist -u: > > line 1: no partition found > line 2: no partition found > line 3: no partition found > line 4: no partition found > ..etc > > Certainly the formatting can't be causing this. I see no difference in the > information in these two files either. Am I missing some special character > or some mystery something or other? I'm at a loss. Ideas? Anyone? > > Thanks, > > -joe > > PS, here is my bash script. It's still a work in progress and is based off > a script (by E M Recio) I found on the cyrus list. E Recio had "<\t>" in his > script but I took it out b/c it didn't seem to matter, the ctl_mboxlist -u > fails regardless of its presence. I left them in this version though so you > could see what I am talking about. BTW, I'm not very good with bash scripts, > so be kind. :) > > Here is the script: > > #!/bin/bash > # > # Requires: valid cyrus spool directory > # sudo (to run as cyrus, or similiar appropriate user) > # > # Result: reads the spool directory and creates a text version > # that can be imported to the mailboxes.db file using > # ctl_mboxlist. > # Notes: > # The directory structure on my system is a/user/auser, b/user/buser, > c/user/cuser > # If your directory structure is not like this, EG, it may be > # /var/spool/imap/user and all the usernames are in one spot > # (var/spool/imap/user/auser), then you will have to make some changes. > # > # Credit: original script obtained from E M Recio <erecio at lo-tek.org>. > Modified > # by Joe Hrbek <jhrbek at gplsinc.com>. > # > # > # ------------------------------------------------------------ > > # Path to cyrus utilities > # Change as needed > util=/usr/lib/cyrus-imapd > > # Path to cyrus spool > # Change as needed > spool=/var/spool/imap > > # ACL super user (should be cyrus) > # Change as needed > acluser=cyrus > > # Replace next line with however you stop cyrus > # ie: killall master etc etc. > #/etc/rc.d/init.d/cyrus-imapd stop > > # Verify this path, change as needed > # This will save your existing mailboxes.db file (if you have one) > #mv /var/lib/imap/mailboxes.db /var/lib/imap/mailboxes.db.$$ > > # Change to the imap spool directory > cd $spool > > # Clean-up > if [ -f /tmp/newmboxlist.txt ] > then > rm -f /tmp/newmboxlist.txt > fi > > # Tracking variables > messages=0 > users=0 > subfolders=0 > > # Build our new mailbox file > > for i in `ls` > do > if [ -d $i/user ] > then > for j in `ls $i/user` > do > echo > "user.$j<\t>default<\t>${j//^/.}<\t>lrswipcda<\t>$acluser<\t>lrswipcda" > >>/tmp/newmboxlist.txt > : $[users++] > for k in `ls $i/user/$j` > do > if [ -d $spool/$i/user/$j/$k ] > then > echo "message folder found, saving: $k" > echo > "user.$j.$k<\t>default<\t>${j//^/.}<\t>lrswipcda<\t>$acluser<\t>lrswipcda" > >>/tmp/newmboxlist.txt > : $[subfolders++] > else > echo "email message, skipping: $k" > : $[messages++] > fi > done > done > fi > done > > # > # Now we have everyone's base directory in /tmp/newmboxlist.txt, do: > # > > #chown $acluser /tmp/newmboxlist.txt > #sudo -u $acluser $util/ctl_mboxlist -u </tmp/newmboxlist.txt > > # and then: > > #for i in `ls` > # do > # if [ -d $i/user ] > # then > # for j in `ls $i/user` > # do > # sudo -u $acluser $util/reconstruct -rf user.$i > # done > # fi > #done > > > # Print results > echo "$users users were found and saved." > echo "$subfolders subfolders were found and saved." > echo "$messages messages were detected in the mail spool (no action taken)." > echo "Mailbox reconstruction complete. A plain text copy can be found in > /tmp/newmboxlist.txt." > > # EOF > > >