December 16th, 2007
This topic wasn’t on my “to do” list, but it came up. So here it is.
Use of procmail to filter emails is definitely not a new thing, that is what it does after all. But in my attempt to configure it, I found very little clear information about support for "Maildir" style delivery amongst the wealth of documentation on the subject.
The 2 main differences in a .procmailrc that works with Maildir, is the trailing slash on the MAILDIR value and the way target folders are specified.
eg. The start of my .procmailrc looks like this:
MAILDIR=$HOME/Maildir/
DEFAULT=$MAILDIR
:0
* ^To:.*(@lists\.danga\.com)
.List/new
So, the 2 points to note, as I said are. The maildir path ends in "/" and the destination is a folder within the Maildir, which is a hidden directory with its own set of cur/new emails in it.
Thanks to procmail, I now only have one location to maintain my filtering rules. My email can then be accessed through IMAP from work, home, laptop and webmail without them being moved into the wrong folders.
July 25th, 2007
It is often useful to be able to rename multiple files at the same time. Typical cases include changing a file extension (eg. *.jpeg to *.jpg) or renaming a set of files moved from one server to another (such as when repairing database replication, eg. slave1-bin.* to slave2-bin.*)
It is possible to write a shell script that will perform this task, but the ones I have seen are cumbersome and not very intuitive.
There is a script, I believe it comes bundles with Perl installation (at least on Debian), that allows files to be renames using regular expressions. It is simple to use, but lets you harness the power of perl regular expressions.
The basic syntax that I use most often involves using a substitute command (similar to those used in sed for example)
eg: Rename all jpeg images to jpg files in the images directory.
rename 's/\.jpeg$/.jpg/' images/*
Mmm… Regex…
May 13th, 2007
If you have ever mistakenly installed grub (or any other boot manager) onto the MBR of the wrong drive (usually during setting up additional multi-boot OSs), you’ll know it can be a pain to get rid of. Most sources out there are for when you accidentally override the windows boot manager with an common *nix one (grub or lilo). This involves using the windows "repair" console on the CD.
When you are running a pure linux system, this isn’t a useful option. This is the solution I found to wipe and re-install grub:
This will probably need to be done from a live CD, as if your MBR is broken, you probably can’t boot your installed system.
-
Wipe the MBR
The first 446 bytes of the drive make up the Master Boot Record, the next 66 (totalling 512) is partition information, you probably don’t want to wipe that unless you intend of re-partitioning (and/or formatting) your disk anyway.
Use `dd` to "zero" those 446 bytes:
dd if=/dev/zero of=/dev/hd? ds=446 count=1
-
Chroot into your installed system
Set up and `chroot` into your main OS
mkdir -p /mnt/root
mount /dev/hd? /mnt/root
mount -t proc none /mnt/root/proc
mount -o bind /dev /mnt/root/dev
chroot /mnt/root /bin/bash
-
Reinstall grub in the correct MBR
Start the `grub` console
grub
then, at the grub prompt:
find /grub/stage1
root (hd?,?)
setup (hd?)
If you "boot" is not on a seperate partition, you the first line might need to be
find /boot/grub/stage1
Assuming your configuration is correct (i.e doesn’t need to be changed since before it broke) you should now be able to boot into your installed system again.