On Fri, Oct 13, 2000 at 11:31:03PM -0700 or thereabouts, Claus Fischer wrote:
> I have a laptop which is sometimes disconnected from my main PC.
> I want to use mutt alternatingly on both systems, for the same
> inbox and mail folders.
> 
> Does anyone have a proven method of doing that?
> 
> Like that:
>              work on main PC
>              synchronize
>              disconnect
>              work on laptop
>              connect
>              synchronize
>              ... [ start over ]

There's a few interesting issues here...  Differences arise depending on
whether your main PC connects to the internet while the laptop is
disconnected or not.  If there's no internet connection happening, you could
do something as simple as copy the more recent file over the older version
in either direction.  OTOH, if the main PC is receiving mail while the
laptop's away, you,ll need a more sophisticated solution.  I'd be thinking
of something along the lines of a combination of pop, procmail and formail.  
For example, you could do something like

cat ~/mbox | /usr/bin/formail -D 8192 msgid.cache > laptop:~/mbox
cat laptop:~/mbox | /usr/bin/formail -D 8192 msgid.cache > ~/mbox

and similarly for other folders (I don't know what the "8192" bit means above, 
I just copied it blindly from Telsa's .procmailrc).  If you create a new 
folder on one machine, a script like the following should duplicate it on the 
other one.

#!/bin/bash

# Synchronise mail folders on two machines
# We'll assume that somehow (NFS?) the user's laptop $HOME directory has
# been mounted as $HOME/laptop on the desktop machine

# First we process the mail on the desktop machine
cd ~/
for MAIL_FOLDER in (./mbox `echo Mail/*`); do
cat ~/$MAIL_FOLDER | /usr/bin/formail -D 8192 $MAIL_FOLDER.msgid.cache > 
~/laptop/$MAIL_FOLDER
done

# Next we process the laptop
cd ~/laptop
for MAIL_FOLDER in (./mbox `echo Mail/*`); do
cat ~/laptop/$MAIL_FOLDER | /usr/bin/formail -D 8192 $MAIL_FOLDER.msgid.cache > 
~/$MAIL_FOLDER
done

# That's it.  It's up to the user now to keep the mail folders trim to avoid
# lots of old messages from being reprocessed!

This should synchronise all mail folders in either direction and duplicate
new folders also at the cost of reprocessing *every* email message in your
possession!  

Note: usual disclaimers apply, this has not been tested.  If it breaks, you
get to keep both pieces.  The "formail -D" bit should be properly researched
before using it on your valuable email.
 
> 3. I need to guarantee that mutt isn't running while I do the
>    rsync, otherwise something will be corrupted.
> 
>    Is it possible to gracefully terminate a running mutt?
> 
>       killall -QUIT mutt
>           mutt:
>           -> kill editor
>           -> postpone currently composed message
>           -> do a `quit' (including expunge)
>           -> remove pid file
>           -> exit(0)
>       wait for pid file to go away and rsync
>       [ just dreaming ]
> 
I don't know if it's necessary to kill mutt using this method.  I'm
certainly running mutt when new mail arrives and gets added to the currently
open mailbox.  I think, since formail and mutt are used to getting along,
there's no need to worry.  That's nice because it means you can set up a
cron job to keep the machines synchronised or maybe have something in the
user's .login and .logout to check if the two machines are connected and if
so, synchronise!
> 
> If someone has experience with that situation I would
> appreciate scripts or comments; otherwise I'll experiment
> and perhaps report back.
Experiment won't you...
> 
> Regards,
> 
> Claus
> 
Waiting to hear what happened... :-)

-- 
Conor Daly 
Met Eireann, Glasnevin Hill, Dublin 9, Ireland
Ph +353 1 8064217 Fax +353 1 8064275
------------------------------------

Reply via email to