Thursday, January 24, 2008

Installing TrueType Fonts on Debian

Fonts. A huge subject. Complicated stuff. I don't know sh*t about it.

All I wanted was to edit a simple old Word document, using some fancy fonts. I have the TrueType (TTF) files available, and I wanted to install them and edit the file with OpenOffice. It took me quite a while and a few failed attempts before I figured it out.

If you're using GNOME this is rather easy:
  1. hit <CTRL>-L with the desktop visible, or in a nautilus window
  2. enter fonts:// and hit <ENTER> - you should see icons/list of all the fonts installed
  3. open another nautilus window, navigate to the location of the TTF file you want to install
  4. drag and drop the TTF file into the fonts window
Done.

I had to exit/enter GNOME in order to get the fonts to appear in OpenOffice Writer.

You can also install fonts with dfontmgr. I tried it and it works, but even with this graphical tool, it's quite a hassle when compared to the GNOME way of doing it.

And, of course, the command line approach:
  1. copy the fonts to /usr/share/fonts/truetype/<new-directory> (as root) or to ~/.fonts/
  2. run fc-cache -fv
Enjoy.

[9 Feb. 2008] UPDATE: dfontmgr is now obsolete - see Debian bug #282225.

Thursday, January 17, 2008

Automatic Backup of a USB Disk Upon Connection

Lately I started carrying with me an external USB hard disk. I find it useful for moving files around that I need to access wherever I go. When I come back home I usually connect it to my laptop.

I wanted to backup the files on the disk automatically, as soon as I connect it, without any interaction. Call me lazy.

There are two issues to solve here:
  1. how to run a script as soon as the disk is connected ?
  2. how to cause Bacula to run a backup job on demand (and not periodically) ?
The first issue is easily solved by adding the following udev rule in /etc/udev/local.rules that I already maintain for managing external disks:
KERNEL=="sd?1", ATTRS{serial}=="300000064029", ACTION=="add", SYMLINK+="aluminum", RUN+="/etc/bacula/scripts/backup-aluminum"
this runs the specified script (RUN+="/etc/bacula/scripts/backup-aluminum") upon addition (ACTION=="add") of the first partition (KERNEL=="sd?1") of a disk with the specified serial number. Along the way this rule adds a symbolic link to the newly added partition at /dev/aluminum.

The script being run has to exit or background as soon as possible, so as not to disrupt udev.

My script runs a backup job by calling bconsole:
#! /bin/bash
/usr/bin/bconsole -c /etc/bacula/bconsole.conf <<EOF
run aluminum-backup-job
yes

EOF
and here is the definition of aluminum-backup-job, in /etc/bacula/bacula-dir.conf:

Job {
Enabled = no
Name = aluminum-backup-job
Client = machine-cycle-fd
JobDefs = "DefaultJob"
FileSet = aluminum-fileset
Pool = aluminum-pool
Full Backup Pool = aluminum-full-pool
Write Bootstrap = "/mnt/elements/backup/aluminum.bsr"
ClientRunBeforeJob = "/etc/bacula/scripts/mount-aluminum"
ClientRunAfterJob = "/etc/bacula/scripts/umount-aluminum"
Priority = 10
}

The trick is to mark the job as disabled! This means that Bacula will not attempt to run it according to the schedule defined in DefaultJob, but it can still be run manually.

Saturday, January 12, 2008

New External DVD Rewriter

The super-multi DVD rewriter drive on my wife's laptop is not so super anymore. It stopped reading DVDs. It can burn DVDs, but it can't read any. It's still covered by warranty, but my wife can't part with her laptop at the moment.

My own laptop's DVD/CD drive broke down several years ago, shortly after the warranty expired...

I was planning on buying an external DVD rewriter drive for my laptop, but was reluctant to shell out the money, and frankly, I was worried that I'll have a hard time getting it to work with Debian. The current hardware problem was just the right excuse for me to dive into it.

So, for any of you planning to purchase such a toy: I got myself a shiny new LG GSA E60L external DVD rewriter. I took it out of the box, hooked it to the mains and a free USB 2.0 port and it just worked. Imagine my surprise.

Out of the 6 DVD-R that I burned already, one was bad, and I'm inclined to blame the software involved. I burned the first with Brasero, and it reported an error half way through the burn process. The rest I burned with K3b - no failures here.

K3b writes at a 4x rate, while the media is marked as "8x certified", and the drive itself is advertised as 20x. But it does write.

I haven't looked into the drive's LightScribe feature yet, but I guess I'll have to - once my wife realizes the potential...