Friday, 2 September 2011

Importing a whole bunch of MH mail files into dovecot

I had some old MH mail that I recovered from backup that I wanted to import into my dovecot server. This is personal mail so I will only describe how to do it for my account. The MH file paths were of the form:


from/alice/1
from/alice/2
from/bob/1
from/carol/1


I wanted to import the alice mail into the logical dovecot mail folder Archives/from/alice and similarly for the others. (Archives is a Thunderbird standard.) In my dovecot setup however, the corresponding maildir directory is ~/Mail/.Archives.from.alice


First I shut down Thunderbird so that it wouldn't interfere during the second step later. This script does the job (backslash continuation inserted for clarity):


for d in from/*
do
  for f in $d/[0-9]*
  do
    /usr/lib/dovecot/deliver -s -m \
      Archives.${d/\//.} -p $f
  done
done


See the documentation of deliver for the meanings of the -s -m and -p options.


You can track the progress of the import by following the syslog file for mail. Any failed imports go into INBOX.


This second step is not required, but I am obsessive. I wanted each imported file to have the same timestamp as the old one. This script uses findup from the fslint toolkit to collect the duplicates (backslash continuation inserted for clarity):


/usr/local/src/fslint-2.42/fslint/findup \
  from ~/Mail/.Archives.*.* > /tmp/dups


This generates pairs of duplicates in /tmp/dups separated by a blank line. This script then applies the old timestamp to each new file.


while read a
do
  read b
  touch -r $a $b
  read c
done < /tmp/dups


I still have to figure out how to mark all the old mail read from the CLI. I just went into Thunderbird and marked each folder read. If you have a good solution, please do comment.



Monday, 2 May 2011

Truth is stranger than fiction, or, The Internet rocks

A friend of mine gave me a dead Dell Latitude D600 to look over in the hope that I could revive it. The symptom was that it wouldn't power up.


Well it did power up for me on my bench and I proceeded to update the software and clean the disk. Then the bug struck: pressing the power button would only cause the LEDs to flash rapidly for a few seconds and the machine would sink into inactivity again.


A dead clock battery can cause this because the CPU has no source of timer events for the BIOS code. Fortunately in this model, the clock cells are very accessible. I measured the three of them and their voltage was well above the 7.2V required. So that wasn't the problem.


So I did a search on the Internet and found this page on FixYa. The top solution was to depress F7 and F8 while booting. I was skeptical but it was simple to try. Lo and behold, the machine fired up. Apparently this model experiences a lot of contact problems with the BIOS chip which is just underneath F7 and F8.


The owner told me that a repair shop had assured him that the machine was beyond repair. Maybe they need to be told about this thing called the Internet.

Saturday, 23 April 2011

How to access CIFS shares from a user account on Ubuntu Lucid

A friend of mine has a Samba server which I set up for him. His problem was that although he could see the shares from the file browser using Connect to Server, they were not accessible from Thunderbird for attaching to emails, etc. and he had to do a copy to a local directory first.


I did a search and found tips involving setting up fstab. This was not satisfactory because the machine was a notebook and the server would not be accessible while on the road. Tips involving autofs and automount were also not satisfactory because of the complicated setup.


I figured that since the file browser could see the share, it must be mounted somewhere. The output of mount showed that it was mounted on $HOME/.gvfs. The problem is that theThunderbird file selector does not display dotfiles. Other programs may have a similar restriction. My solution was this:


ln -s .gvfs GVFS


I then instructed him to look for his share under GVFS. Actually Thunderbird can navigate to dotfiles, you have to click on the Type a file name icon at the top left and type in .gvfs, but I figured that this was much easier for the user.


If you make a bookmark in the file browser and also tell it to remember the credentials for the connection, it should be one-click to mount. I think this should work for the other types of mounts that the file browser can do, e.g. FTP.

Saturday, 19 February 2011

Cassette sales in 2010 in Australia

From a newspaper report on music sales in 2010 in Australia. This is amazing, they should find the seller and buyer and congratulate them for making an interesting statistic. Exactly 3, wow!