Friday, 29 December 2006

Using an NSLU2 as a USB print server

(Update 3.ix.2011: This article is ancient.  I now run debian on my
slug rather than unslung and it is no longer serving as my print
server.  This article is kept for posterity)

I've configured my NSLU2 as a USB print server using CUPS.

My NSLU2 "Slug" is running OpenDebianSlug, and followed the
instructions at
for instructions on how to install the `usblp` module and CUPS.  To
summarise, as `root`

    dpkg --force-all i kernel-module-usblp_XXXX.ipk
    depmod -a
    apt-get install cupsys hotplug

I then configured my printer as `printer` using the `links` text-based
browser on the slug itself.

In windows, I set up an IPP printer to print to my CUPS printer.

The set up works fine, except for one major flaw.  If I send a job to
the printer while it is switched off, CUPS can't print and so stops
`printer`.  When the printer is switched back on, `printer` still
accepts print jobs, but it is stopped.  The only way to get the
printer going again is to Start the printer, for example via the web
interface on port 631.

I found a solution by adapting the script found on
I created a file `/etc/hotplug/usb/usblp` with the following contents:

    # Arguments :
    # -----------
    # ACTION=[add|remove]
    # DEVICE=/proc/bus/usb/BBB/DDD
    # TYPE=usb 

    if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then
      /sbin/modprobe printer
      for i in `/usr/bin/lpstat -v |awk '$4 ~ /usb:/ {print $3;}'|sed -e 's/://g'`;do
        /usr/bin/enable $i
        /usr/sbin/accept $i

What this does is Start `printer` (that's what `/usr/bin/enable` does)
whenever it detects a hotplug `add` event.  I had to install

    apt-get install cupsys-client

to get the command `/usr/bin/enable`.

Saturday, 27 May 2006

How to get Wake-on-LAN (WOL) to work in Fedora Core

(Update 3.ix.2011: This content is from 2006.  I don't have the
hardware any more so I cannot reproduce what is described here.  I am
keeping this around for posterity in case it might be of use to

Recently I've been wrestling with WOL for one of my linux servers.  I
found a WOL client called `etherwake`, which installs just fine in
OpenDebianSlug using the command `apt-get install etherwake`.

However, I found that I was having problems on the other end.  I
noticed that if I switch off the computer using the front power switch
at the GRUB boot menu, I could wake the machine using etherwake,
whereas if I use `shutdown -h now` from within linux, nothing happens.
The tell-tale sign is that the port light on my 3Com router/switch is
lit in the first instance, and dark in the second.

A bit of googling around suggested that this is a common problem.  The
explanation was something along the lines of "linux shuts down your
network card on OS shutdown".  (For the pedantic, this should be
rephrased as "most linux distributions shutdown the network card on
shutdown").  The Gentoo Wiki's page on WOL suggested [removing the
`-i` option from `halt`][gentoo].

Starting from this, I managed to get my machine to shutdown and be

## Server config

My machine is running Fedora Core 4, though these change would likely
work for other versions of Fedora and Redhat/CentOS.  I changed the
script `/etc/init.d/halt` so that the last few lines were changed from

     HALTARGS="-i -d"
     [ -f /poweroff -o ! -f /halt ] && HALTARGS="$HALTARGS -p"

     exec $command $HALTARGS


    [ -f /poweroff -o ! -f /halt ] && HALTARGS="$HALTARGS -p"

    /usr/sbin/ethtool -s eth0 wol g
    sleep 5 # this pause seems to be important!

    exec $command $HALTARGS

Note the removal of `-i` from `HALTARGS` and the extra `ethtool`
invocation before the last `exec` command.

## Client config

This is the easy part.  I created a file called `/etc/ethers` to map
names to my MAC addresses:

    00:20:ED:5A:00:2B fried
    00:11:09:24:1C:8B white

Now to wake up `fried`, all I need to do is type the following

    sudo etherwake fried

and `fried.rice` wakes up!

[gentoo]: "Gentoo WOL"