CUPS (Common Unix Printing System) and multiple identical printers can be a pain in the butt. Especially, if the printer manufacturers are naughty and do not make the printers serial number public on usb connect.
This shall be a little how-to for all those people who discover the same trouble!
The setup I had to deal with:
– Ubuntu (x64 Server)
– CUPS 1.2.8
– 2x Kyocera Mita FS-1030D attached via USB
The problem:
If you connect both printers, they both get the same ID:
# lsusb
Bus 004 Device 093: ID 0482:0015 Kyocera Corp.
Bus 004 Device 092: ID 0482:0015 Kyocera Corp.
AND (even worse) are both mapped to usb://Kyocera/FS-1030D
An auto-installation on the cups web interface will result in a success, BUT you’ll only be able to print on the first of the two USB devices. So not a good solution.
OK, this is where you want to go:
1. Set up the printer(s) using the web interface.
2. Fire up your console and goto /dev/
3. Find the files usblp0 and usblp1 (depending on your system, there might be a sub folder named ‘usb’. If so, see if there are two files named ‘lp0’ and ‘lp1’ in existance) and pad yourself on the back ;)
4. Edit /etc/cups/printers.conf with your favourite editor.
5. You’ll find the first printer which looks like this:
<Printer Kyocera_FS-1030D_USB_1>
Info Kyocera FS-1030D
Location Local Printer
DeviceURI usb://Kyocera/FS-1030D
State Idle
StateTime 1231879830
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
Leave it like this!! (Otherwise, CUPS web interface will harass you with newly found printers.)
6. Right under the first printer you’ll find the second printer (and the third, the fourth, […]) named <Printer Kyocera_FS-1030D_USB_2> for example. THERE (and on possibly other following identical printers) change the following line
DeviceURI usb://Kyocera/FS-1030D
to
DeviceURI file:/dev/usblp1
The other printers below need their equivalent usb device link. You could to a
# echo usblp1 > /dev/usblp1
which will actually print the word ‘usblp1’ on the printer. If you do so with all of your printers, you’ll know the device link ;)
Ok, we are not quite there, yet. I found a strange behaviour of CUPS, when you switch the printers off over night and turn them on again the next morning. Somehow, having this configuration, CUPS simply quits without following any shutdown procedures. No log entries, no good bye letter, nothing.
In order to detect and overcome this situation, this little script monitors the cups daemon and restarts it if necessary:
#!/bin/bash
#
# cupsMon.sh -- A Monitor for CUPS
#
# @author Henning Weiler
# @version 1.0
#
if [ -r /var/run/cups/cupsd.pid ]; then
CUPSPID=$(cat /var/run/cups/cupsd.pid)
if ps --pid $CUPSPID | grep "cupsd" >/dev/null; then
exit 0
else
rm -f /var/run/cups/cupsd.pid /var/run/cups/cups.sock
/etc/init.d/cupsys start
fi
else
/etc/init.d/cupsys start
fi
I put it in my root home directory and gave it a little ‘chmod +x’.
In your /etc/crontab add the following line:
9 * * * * root /root/cupsMon.sh >> /dev/null
This will run the monitor every 9 minutes. I did not want to run it every minute, since switching on multiple printers may take a while.
If you have any questions or concerns, please comment.
8 Comments