Adventures in Red Hat Enterprise Linux, CentOS, Fedora, OpenBSD and other open source solutions.

Using multiple domains with Drupal

If you have multiple domains, all going to the same website, you can redirect traffic to your 'primary' or 'default' domain instead of serving the same content on all domains. Google measures your websites authority over the number of links to you website, if you have several domains, some using www. some not, then that authority is spread across all those (sub-)domains.
Another reason to use 301 redirects is that google maps uses a key, that is dependant of the url of the client. Not using this trick, would result in error-popups about an error in your API key on your visitors computer.

So; use 301 redirect to send all visitors to one default domain. Here is how to set it up, it should work for any website, but I have tested it on drupal

Open the .htaccess file that comes with drupal. (Be aware each update of Drupal will overwrite that file!) You will find these lines somewhere:

<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  # To redirect all users to access the site WITH the 'www.' prefix,
  # ( will be redirected to
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$$1 [L,R=301]
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # ( will be redirected to
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$$1 [L,R=301]

Read what is described and add a few lines. You can use regular expressions to tell the Rewrite Engine what to match.

  RewriteCond %{HTTP_HOST} ^www\.meinit\.nl$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^www\.meinit\.eu$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^www\.meinit\.com$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^www.drupal\.nl$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^www.robertdebock\.nl$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^meinit\.eu$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^meinit\.com$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^drupal\.nl$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

  RewriteCond %{HTTP_HOST} ^robertdebock\.nl$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

As you can see, this single website can be accessed using the domains:

The approach described above is very simple, you could also use regular expressions to make one RewriteCond line, but to keep it readable when adding a domain, or upgrading Drupal, I have chosen to split each domain into a new line. You could also introduce loops that redirect from "a" to "b" to "a", etc.

Ergonomic keyboards reviewed

On a daily basis I use ergonomic keyboards, as "straight" keyboards make my wrists go painful. If you are in pain, read this article.

Years ago I started out with straight keyboards, and realized an ergonomic keyboard could improve my typing speed. For me the reason for slowly switching to ergonomic keyboards, was related to typing speed, not RSI, (repetitive strain injury) or pain in the wrists, shoulders, arms or fingers.

Microsoft Natural keyboardLikely the most used is the Microsoft Natural Keyboard Elite. This is a PS2 model, which is largely deprecated by now. Microsoft still sells USB versions with fancy multimedia keys. This keyboard however has helped me for years, was cheap and durable. As it is still quite common in office environments, try using this keyboard instead of straight types. It only takes a day or so to get used to it.

Logitech Comfort keyboardThere are some similar keyboards like Logitech Comfort Laser and possibly other. I have not tried them all, but since their design is quite similar, I assume that the experience is almost the same.

Kinesis Advantage KeyboardMy latest (and best, but most expensive) keyboard is the Kinesis Advantage keyboard. As you can see, this is a different type of keyboard. The hollow cups that capture the keys help to get your hands in the correct position. You use this keyboard as a QUERTY type keyboard, the only difference are the "special" keys: back space, space, delete, home, end, ctrl, alt, enter, page up and page down. You control these special keys with your thumbs.
This keyboard does require some getting used to, but it's well worth it. After a week, and some hours of training (comes with the keyboard) you are able to type at acceptable speed again.
Keys are (re-)programmable, which means you can copy keys to another location. As I use Linux the most, I have copied the alt key over the windows key. The keyboard comes with a few physical keys that you can replace, like ctrl, alt, windows and those type of keys.
There is a two-port USB hub integrated. You could connect mice and touch pads.
The angle between the two keypads could have been a little bigger. Sometimes it feels like the hollow cups are a bit too straight. Another thing, the top row of keys (esc, f1, f2, etc) is some sort of sticky rubber. Especially when using the escape key often, I accidentally hit f1. These keys are not positioned optimally, but I have accepted this con.

Datahand keyboardAnother keyboard is the Datahand. This keyboard is the most expensive of all listed keyboards, and looks so alien that it shocks potential buyers like me. I have one colleague though that uses it and is very happy with it. This keyboards also drives the pointer/mouse on the screen. Likely if you suffer the worst type of pains/RSI, this keyboards could safe your job.

Intergrating Google maps into a drupal website

It might just be me that does not fully understand how to use the Google Maps module for Drupal, so let me guide you on how to setup this module within your Drupal website.

First step: Download and install the two modules GMap and Location. After the files are installed, activate the modules "Gmap", "Gmap location" and "Location".

Second step: Go to the Google Maps API signup page and obtain a key. This key is the approximately 85 characters long.

Third step: Paste that key into the setting of Gmap, located at /admin/settings/gmap.

Fourth step: This might be optional, but was required for me; Enable the "GMap filter" in your filters, located at /admin/settings/filters

Fifth step: Create content with the gmap tag. Here is one example for which the code looks like this: (replace "WORD" by "gmap", sorry, drupal translates really well!)


Javascript is required to view this map.

What you see is the neighborhood where I live, Utrecht. I used Webgeer media's website to guide me a bit.

Using Keychain for SSH logins

I would like to make a short intro to Keychain, this utility makes handling SSH keys easier and also saves you having to type in your passphrase every time you SSH to a remote machine using public key authentication.

Most Linux distributions and BSD variants already have Keychain packaged or easily installable in some way. I will leave installing keychain as an exercise to the reader. Also, I recommend following Mr Robert's fine guide on using SSH keys before starting to setup Keychain.

Once you have your SSH keys configured and Keychain installed then using keychain is quite easy. The following steps are required :

  • Initial Test
  • Modify your shell startup scripts to automatically start Keychain

Initial Test

So, our first step is to manually step through the process of feeding Keychain our SSH keys :

[email protected]:~$ keychain ~/.ssh/id_rsa

KeyChain 2.6.6; Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL

* Initializing /home/keychain/.keychain/silverado-sh file...
* Initializing /home/keychain/.keychain/silverado-csh file...
* Initializing /home/keychain/.keychain/silverado-fish file...
* Starting ssh-agent
* Adding 1 ssh key(s)...
Enter passphrase for /home/keychain/.ssh/id_rsa:
Identity added: /home/keychain/.ssh/id_rsa (/home/keychain/.ssh/id_rsa)

[email protected]:~$

When it asks for your passphrase, enter the passphrase you used during key creation. Once this is successfully completed you need to setup the shell environment. As you can see, Keychain creates many files that contain the required environment variables to make the ssh-agent information accessible across logins and shell instances. You will need to source the appropriate file, depending on your shell. I am using Bash, so I will use the silverado-sh file. Another point is that the file name contains your hostname so if your host name is "mymachine" then the file will be mymachine-sh in the ~/.keychain directory.

The method by which we will acquire the variables stored in the silverado-sh (or whatever it is called on your system) will be by sourcing the files. Like so :

[email protected]:~$ source ~/.keychain/silverado-sh

and then to verify the variables are there :

[email protected]:~$ env | grep SSH_A
[email protected]:~$

Now try and log into a machine that uses your public key for authentication, you should not be prompted for your passphrase.

Automatically Starting Keychain and Sourcing Files

Now we don't feel like doing that every time so we can put that in our shell initialisation file, in my case ~/.bashrc. Insert the following, replacing "silverado-sh" with your own Keychain environment file :

keychain ~/.ssh/id_rsa
source ~/.keychain/silverado-sh

Tada! Finished. But for the full Keychain treatment I refer you to the Gentoo Documentation.

Very Simple but Secure Database Backup

I am using the very fine DBMail as a MySQL email backup, more on this in other articles. Please note that this is my first article, so please be gentle. But for now, I wanted to share how I backup this email store and hence a database. I have written a script that :

  • Dumps the relevant database.
  • Compresses the dump file.
  • Encrypts the database using Gnu Privacy Guard (but any method will do).
  • Uploads the database to a remote location using SFTP.

The prerequisites for using the script "as is" are :

  • MySQL dump user with sufficient privileges to dump the required database.
  • ~/.my.cnf configured for user having sufficient privileges to backup the DB. For example:

user = dbuser
password = dbpass
database = dbmail

  • Working GPG installation.
  • Remote backup host running an sftp server.
  • Local copy of sftp OpenSSH client.
  • Keychain for password-less login to remote server. More on keychain in a future article.

Note that this script stems from a quick and dirty script that I wrote for myself so use what is in this article more as a guideline :-) They script itself will require some modification in your environment. And, without further ado, here is the script :

# Author : Fred Clausen <[email protected]>


source $HOME/.keychain/$HOSTNAME-sh
cur_name="$local_dir/$database-`date +%a`.sql.gz"

if [ -f ${cur_name}.gpg ]; then
        rm -f ${cur_name}.gpg

mysqldump --databases $database | gzip > $cur_name
if [ $? != 0 ]; then
        echo "Error dumping data"
        exit 1

gpg -r $gpg_user -e $cur_name

cat > $batch <<END
cd $remote_dir
put ${cur_name}.gpg

sftp -b $batch [email protected]$remote_host

rm $batch

You will obviously need to modify the variables at the top to values suitable for your environment. Also, see how this script recycles file names to keep a week's worth of backups.

Good luck!

Use bash (or sh) to hang a machine

Here is a simple trick, stolen from a mailinglist archive.

Be aware; this command hangs your box! Unless you have ulimited yourself.

:(){ :|:& };:

Now, it that the absolute minimum to hang a box? I guess so, but if you know similar shell fork-bombs, let me know.

Things war is good for

Here is an nice image (shamelessly stolen from a website with weird graphs) that represents what war is good for. Some highlights:

Using tar and ssh to efficiently copy files preserving permissions

Have you had situations where disk-space is sparse, so making full tars (although compressed) is impossible? Here is an ssh trick that could help you copy over files without using too much diskspace.

This trick will tar a directory from a computer, but the file that it would normally create, is standard out, so it is redirected back to the script on the computer you are working on. The computer you are working on extracts the information directly, so there is no location where (redundant) files are stored.

ssh [email protected] "tar czpf - /some/important/data" | tar xzpf - -C /new/root/directory

You are now directly copying data from the "machine-where-precious-data-is" to the machine you are working on, using the benefits of tar (preserving permissions, links, etc) but not being hindered by the difficulties of tar. (making these possibly large files and so on.)
I used this trick to copy users directories from one machine to the other.

An alternative command, reverse and not crossing filesystem boundries:

tar cpf - /some/important/data | ssh [email protected] "tar xpf - -C /some/directory/"

NFS server on OpenBSD, client on Mac OS X

Here is a small reciepe on how to setup an OpenBSD (I used 4.2) NFS server and have a Mac OS X (I used 10.5.1) client connect to it.

First setup the OpenBSD server to server /mnt/sd0a over NFS:

# echo "portmap=YES" >> /etc/rc.conf.local
# echo "nfs_server=YES" >> /etc/rc.conf.local
# echo "/mnt/sd0a -network=192.168.1 -mask=" >> /etc/exports
# portmap
# nfsd -tun 4
# mountd

Now test the share on you Apple:

# mount_nfs -P /private/tmp/test/
# df -h /private/tmp/test
# umount /private/tmp/test

Now because apple used automount by default (check /etc/auto_master on your Apple) you can find the OpenBSD NFS server in the finder:
A screenshot of the finder showing the shared mountpoint.

Screencast: Installing OpenBSD 4.2

A screenshot of the OpenBSD installer.

Another screencast of how to install OpenBSD 4.2 in parallels on an Apple.

Explained is how this installer can be used, how sets can be downloaded and end up with a small working OpenBSD installation. This video is targeted for audience that does not know how to install OpenBSD. If you have some experience with installing OpenBSD, don't waste your time by watching this video.

Syndicate content