mknod tutorial

October 26th, 2008

mknod is a powerful command with which you can create block or character special files. If you view the man page, you’ll see that you can use it to create block device links and character device links. If you don’t know what these are then don’t worry. The purpose of this tutorial is to explore the FIFO (First In First Out) feature.

A FIFO literally does what it says on the box. The first piece of data to go in is the first piece of data to go out.

The usage of the command is:

Usage: /bin/mknod [OPTION]… NAME TYPE [MAJOR MINOR]

Where MAJOR and MINOR are for the special devices mentioned above.
Read the rest of this entry »

rsync over SSH, SSH key login, public keys, automated backups

October 24th, 2008

This tutorial will cover how to set up a simple backup job between two machines using rsync and ssh. You will need HOST A and HOST B, whereby HOST B is your target backup service.


ssh-keygen -t rsa  # Press enter to accept the default options.
mv ~/.ssh/id_rsa ~/.ssh/identity
cat ~/.ssh/

Read the rest of this entry »

Exim, MySQL, Courier IMAP, Courier POP3 & Spamassassin – vdomain and vuser set up.

October 19th, 2008

There’s a couple of guides out there on how to set up Exim, MySQL, Courier and Spamassassin in a virtual user environment but I thought I’d put together a high level basic guide myself.

My installation is running on debian etch 4.0 stable (2.6.18-6-686)

As this is a vdomain/vuser setup, you will not require a system shell/login for the users you add.

To start off, just install the packages you’ll need with apt-get:

apt-get install mysql-server-5.0 mysql-client-5.0 spamassassin, spamc, courier-authlib-mysql courier-imap, courier-pop3.

Now if you already have exim4-* installed which is the default, you have two choices. We want to install our own exim version from source but without breaking the repository. The choices are to either just rename exim4 to exim4.old and then create your new exim install, or alternatively create a dummy empty exim4 package remove exim4-* and install your dummy package. This will resolve the dependancies issue in the package manager. Neither method is particularly clean – I have installed a dummy package personally and removed the real exim4 set of packages.
Read the rest of this entry »

Linux on a Mikrotik 532a , Part 5 Final – OpenWRT and Custom Scripts

October 19th, 2008

Follow on from:

I’ve used OpenWrt previously to this project to build some firmwards for the Linksys Router WRT54 range. OpenWrt is an incredibly powerful and small Linux distro. Although debian is probably better suited to the reasonably powerful hardware, I wanted to give OpenWrt a go anyway.

Unless you’re running a MIPS 4Kc processor on your host which I’m guessing you’re not, you’ll either need to cross compile your binaries, or just compile them natively on the device itself. Compiling on the device works fine as long as you have the relevant packages, however if I was going to build a 2.6 kernel, I’d rather do it on an x86 quad core intel host, rather than waiting a week for the device to do it. I also wanted to minimize the writes on the CF card.

OpenWrt comes with a nice buildroot environment which you can read about and download from using Subversion.

Here is a great HOWTO on getting the build root environment set up on your x86 host.

Also, see: – this is a very complete HOWTO, which is why I’ve not covered most of the installation process and just detailed customizations.

You’ll need to select the RB5xx target for the kernel. Also, run:

make kernel_config

In your build root top directory, and add USB support (as my one is modded for USB which is not RB5xx default.

While you’re there, browse to the networking options and make sure you have everything you want, specifically the schedulers for traffic shaping.

Read the rest of this entry »

Robot: Initial Hardware Order [rev 2]

October 13th, 2008

Follow on from:

I’ve given up on trying to source separate motors, motor controllers, encoders and brackets. I’m concerned that my knowledge of mechanics and motors is limited, and that I’m going to spend too much time and money trying to build a movement package myself.

I’ve decided to go for a good motor/controller/encoder package here:

Wheel Package

Wheel Package

I’ll need two of these, and will have to replace the wheels with the omni directional wheel things I found and linked to in my last post.

I’ll drill the brackets into a thin metal plate, and start building perspex on top. I don’t seem to have paid enough attention to battery/device weight/motor/power and am concerned that the motor and battery combination will not move the device. I don’t yet have an idea of how much it will weigh, but I’ve realized that the perspex is going to have to be as thin and light as possible, and I’m going to have to bear weight in mind with any unnecessary or redundant extra parts.
Read the rest of this entry »

The Robot: Hardware List, Wheel Plan, More Ideas, Steps to launch

October 12th, 2008

Thanks to some further thought and some great comments and suggestions, I’ve got a clearer idea of what I’d like to build, and I’ve devised a preliminary hardware list. I’ve divided this into various categories to help planning and ordering.

My bad wheel plan mockup for 4 wheels and omnidirectional movement:

Base Layout

Base Layout

Please excuse the awful graphics

The base layout should be as follows. The diamond shape is a very thin metal plate which will have the motors and motor casing attached. The metal plate will be at the very bottom of the device. The square (overlayed) will be the acetate base of the unit, and build up to form the base “box”.

I’d like the motor’s to be simple 6-9v, 10W max. motors

Each motor will be held on it’s own bracket and will not be connected via an axle. Each motor will require independant control via a motor controller. The motor controller will be required to convert digital input to variable voltage (5v/7v/9v?) output. 4 speed (4.5v/6v/7.5v/9v>) would also be fine.
Read the rest of this entry »

Linux on a Mikrotik 532a, Part 4 – Customization, Debian Scripts, Shaping, Firewall, NAT, picoLCD

October 11th, 2008

Follow On From: 05 Oct 08 APNIC Box – Linux on a Mikrotik 532a, Part 3 – Installing Debian, Prebuilt Disk Image

Following on from the previous article, I’ve written some scripts which you’ll find in the /root/scripts/ directory of the prebuilt image. I’ve attached and commented them here, as they could also be useful elsewhere. #For setting up a simple bridge
Read the rest of this entry »

Linux Robot, more hardware ideas

October 8th, 2008

Follow on from:

I’ve been giving the layout and hardware of the device some thought. Hardware should be split up as follows:

Main board
At minimum, CPU, IO pin out, RAM, CF/SD, and USB controller. Wifi and/or ethernet would be nice. It will need to be linux friendly of course.

Custom IO board
Connect to Main board via 16 bit bus. The custom IO board will have some logic gate chips and maybe some memory. It will then connect child boards for LEDs, the ultrasonic sensors, switches and relays. The relays will then be connected to the wheels. I’ll consider adding other sensors for temperature, light, etc.
Read the rest of this entry »

Linux Robot – Watch this space

October 7th, 2008

I’ve been struggling to think of a good project to start on. I’m currently writing the APNIC Box series here, and I’m on part 4 of maybe 7 or 8 right now. I like to keep at least one personal project of interest on the go at a time so back to struggling for inspiration.. Feel free to tell me that this is an awful idea and suggest something else, but until I hear otherwise I’m going to roll with it.

Linux Robot – Requirements

Here’s what I’m thinking. Small embedded device, way smaller than the Mikrotik 532a used for the APNIC Box. The board will need USB [as we’re going to use the 5v for charging later]. I’d like to start with a powerful enough board that it can be expanded later with relative ease.

The device will initially have few inputs and outputs. It will support miniPCI, USB, Serial Console, CF card, GPIO or some other good method for controlling a relay board and some motors. The device will have 4 small wheels, maybe rubber [old mouse] balls instead and some ultrasonic sensors, 4, 6 or 8.
Read the rest of this entry »

Diffie-Hellman Key Exchange

October 7th, 2008

Diffie-Hellman Key Exchange is a popular mathematical key exchange algorithm. It allows two parties to establish a ‘key’ over an insecure medium such as the internet. As you will see, it doesn’t matter whether the intercepting party captures each piece of transmitted information, they will not be able to break the key in any way, other than the usual brute force method.

Diffie-Hellman Key Exchange is not an encryption method, it is generally but not always used pre encryption to decide on a shared encryption key.

We will call the communicating parties Bill and Ben. Let Roger be the intercepting party. You can work out these calculations on a calculator:
Read the rest of this entry »

PHP, MySQL, Apache2 install HOWTO on Debian

October 7th, 2008

Setting up a PHP/MySQL/Apache2 environment on Debian is really easy, and as a PHP MySQL Developer, it’s kinda important! I’ll walk through a quick Debian lamp install howto and optimization process. I’ve optimized it for a 1.5Gb to 2GB RAM machine with reasonable load.

apt-get install apache2 php5 mysql-server-5.0 mysql-client-5.0 libapache2-mod-php5 php5-mysql php5-curl php5-cli php5-dev make gcc libc6-dev automakemysqladmin password 'NEWPASSWORD'

Now download eaccelerator from
Read the rest of this entry »

APNIC Box – Linux on a Mikrotik 532a, Part 3 – Installing Debian, Prebuilt Disk Image

October 5th, 2008

Follow on from 01 Oct 08 APNIC Box – Linux on a Mikrotik 532a, Part 2

The device runs a 2.4.30 kernel on a debian woody (mipsel) environment. If anyone can contribute anything for 2.6.x and debian etch, that would be great.

Installation instructions:

Read the rest of this entry »

APNIC Box – Linux on a Mikrotik 532a, Part 2 – Hardware Modifications

October 1st, 2008

Follow on from 01 Oct 08 APNIC Box – Linux on a Mikrotik 532a, Part 1

Custom Hardware Modifications

Here’s a labelled image of the inside of the device. You can also look towards the bottom left of the image for my simple solder modifications. Enlarge the image to see the labels.

APNIC Box Image 2

APNIC Box Image 2

1. External 2.4GHz/5GHz antenna. Same on opposite side.
2. 5V solder point
3. 5V connector for miniPCI USB card
4. 2x 2USB Headers. 1 Header in use providing 2x USB interfaces, one to regular host connector for mass storage or other usb connection. Other port for picoLCD on top
5. 512MB CF card
6. miniPCI USB controller

On the underside of the board there is a single miniPCI socket which houses an Atheros 5212 802.11a/b/g miniPCI card. It has two antenna outputs which run under the board and two the two external antennae. I haven’t taken a picture of this but if anyone really wants to see it, I will power down the device, get a picture of it and post it here.

Read the rest of this entry »

APNIC Box – Linux on a Mikrotik 532a, Part 1 – The Device

October 1st, 2008

I put this device together for fun sometime around the start of 2007. The ideas that spawned this was using OpenWRT on a Linksys WRT54G access point. A surprisingly powerful and full linux distro with all kinds of advanced capabilities running on a Linksys wireless router which I’d previously thought to be a reasonably dumb device with computing power more comparable to a calculator than a PC. The project opened my eyes to embedded devices, and I wondered what device base I should start with. To cut a long story short and for reasons that I can’t even remember anymore I came across the Mikrotik Routerboard 532A and decided that I should start with that.


APNIC Box Image 1

APNIC Box Image 1

Here’s a picture of the device from the outside with some labels, view the full image to see them.

1. Status LEDs. Blue at the bottom left shows it’s on, orange at the top right shows that there’s wifi activity.
2. Ethernet (eth0)
3. Standard Serial Console (57600, 8 N 1)
4. Ethernet (eth1)
5. Ethernet (eth2)

Read the rest of this entry »

Playing poker on Linux

October 1st, 2008

Linux is always gaining popularity on the desktop. Playing poker on Linux isn’t that hard and you’ve got a few options:

1. Find something web or flash based. Poker Room, Euro Poker and Hollywood Poker are a few examples of sites that offer that.

2. Java is a cross platform SDK. Absolute Poker, Party Poker, Poker Room, and quite a few others offer Java play.

3. Wine. I managed to get my favorite poker site Titan Poker working perfectly in Wine. Here are instructions for debian based systems:

apt-get install wine
wget <location>/setup.exe
wine ./setup.exe

It’s that easy! If you get a regsvr32 error during setup, it is safe to ignore it.

Double click ‘Titan Poker’ which will now have appeared on in ~/Desktop/Titan Poker

It works well, graphic and game quality is the same as Windows, sound also works with the right Wine configuration.