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`.