Long time..... Hope all is well!
If you're insisting on using ONLY shell scripting, then I think there's
a bit of tedious work in coding up your needs - especially if you want
to make it reasonably bullet-proof, etc, etc. IMO, BASH (etc) are
finnicky, and, when coding, a programmer has to be a bit conscious of
the exact syntax, significance of spaces, semi-colons, brackets/braces,
etc... I don't like this hit on the real app's functionality...
Over recent years, I've written a number of biggish (?) scripts (say, 10
pages+ each), and they were a bit "painful". Ultimately, every issue was
solvable, but some "solutions" require serious probing, testing, etc. If
you do end up writing some script functions, and you get stuck
somewhere, do give me a shout anyway - I may have hit it already...
If I had to write a small script, like your proposed one, I'd extend
your pseudo code a bit more, perhaps drop that "users" table into the
source, insert the loops, etc, and probably use a syntax (and compiler)
like FreeBasic - it'll almost accept the pseudo code!!! And it runs on
Linux, Windows, etc... I've not used the GUI features in it very much,
and some other product may be more suitable for GUIs. If that option is
open to you, we'll have the thing running "in no time"...
- Mike K.
Patrick O'Connor wrote:
> I've got a bunch of mails (in Maildir format) to move from one server to
> another. Only problem is that there's lots of them (60 accounts in 5
> different domains, 70GB total). I'm trying to dip my toe in the waters of
> shell scripting but am a bit lost. If anyone can help out I'd be glad to
> provide suitable beverages at the next potd!
>> I've written a "pseudo script" which just outlines how I think the job could
> be done but is lacking in some minor details like proper commands, array
> setup and generally anything to make the script usable! It should help to
> describe the task though....
>> ---Start "Pseudo Script"---
> # text file containing table mapping old usernames to new usernames
> $users = /location/users
>> #$archivelocation has a bunch of folders named oldusername1, oldusername2
> etc each containing the Maildir directory plus other files/directories.
> #The Maildir directory contains miscellaneous courier mail files and "new"
> and "tmp" directories as well as the "cur" directory.
> $archivelocation = /location/of/maildir/archives
>> #$newlocation has a bunch of folders named newusername1, newusername2 etc
> containing the Maildir directory. They're all empty so overwriting is not a
> $newlocation = /location/of/new/maildirs
>> #Needed to set permissions on copied content.
> $domainusername = somedomain
>>> #All I want to move is partial contents of the Maildir folder i.e. the "cur"
> folder and all .folders (except .Trash).
> #I need to copy the only the required contents from the old Maildir to the
> new and change ownership/group
> #of the copied files to "newusername*.domainusername:$domainusername"
>> #With my (very basic) knowledge of commands I would do this...
>> cp -frv $archivelocation/$oldusername1fromusersfile/Maildir/cur
> cp -frv $archivelocation/$oldusername1fromusersfile/Maildir/./*
> rm -fr /$newlocation/$newusername1fromusersfile/Maildir/.Trash
> chown -R $newusername1fromusersfile:$domainusername
>> Repeat for each username combo....
>> ---End "Pseudo Script :-) ---
>> Contents of "users"
>>> Any idea how I could put together??
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!