Saturday, May 01, 2010

Configure CUPS as print server for USB printer on WD MyBook

Hi all,

A while back I got myself a Western Digital (White Light) MyBook. It comes with an USB port and I want it to serve as a printer server. I found out that it runs Linux and a great group of people has done all the groundwork to get this going. The main source of information is

http://mybookworld.wikidot.com/

There is a tutorial on how to set up cups on the WD MyBook but this did not work out for me. Searching for hours I collected information from various sources and pieced it togehter. When I had the pieces together I came across a German tutorial which would have save me many hours.

http://members.aon.at/berwinter/mbwe/mbwe_en.html

which is referenced from this thread.

http://mybookworld.wikidot.com/forum/t-180724/

I am going to reproduce this here as often it gets lost. Thanks to these people who deserve all the credit.

Tested with firmware 01.00.16, 01.00.18 and 01.01.16!


Updates


  • Firmware 01.01.16 tested
  • Firmware 01.00.18 tested
  • Addgroup added
  • Print Test Page
  • Add a printer using web interface

Thanks to mad_ady and Fidatelo
of mybookworld.wikidot.com for their Feedback!


Preparations:


First of all must be, if not already geschähen, SSH is enabled in
the web interface. Then you can log in using Putty, for example on the
console. (User: root / Password: welc0me)

First, the MBWE for Optware will be prepared. This is best done with
the script by Frater, that also makes some other improvements



wget -O prep_whitelight http://wd.mirmana.com/prep_whitelight
sh prep_whitelight



This takes some time and there are many packages downloaded and
installed. Then Crond should be disabled so that the disks do not start
every 15 minutes.


Install Cups:


Meanwhile cups can be installed directly from the sources and you
have to compile anything yourself. Simply execute the following as root
on the console MBWE:



/opt/bin/ipkg install cups<br />/opt/bin/ipkg install cups-pdf<br />/opt/bin/ipkg install cups-doc<br />/opt/bin/ipkg install cups-driver-gutenprint<br />



With cups-doc is needed for the web interface of cups. During this
moment is cups already bootable, but it can not find the connected USB
printer. This is a kernel module needed.


Kernel module to install:


The module was compiled by me from the Western Digital sources.
In order to save you the work you can download the module here, please
only use kernel 2.6.24.4.




mkdir /lib/modules/2.6.24.4/kernel/drivers/usb/class/

wget http://members.aon.at/berwinter/mbwe/usblp.ko.whitelight -O
/lib/modules/2.6.24.4/kernel/drivers/usb/class/usblp.ko



The modules can now be loaded with insmod. However, the file
incorrectly awarded rights. We use a startup script that makes all the
settings at startup, and cups start.



For this we create the file / opt/etc/init.d/_SK88cupsd with the
following contents:



#!/bin/sh<br />#<br />#<br />#<br />case "$1" in<br />        start)<br />                if ( [ ! -c /dev/lp0 ] ) then<br />                        mknod /dev/lp0 c 180 0<br />                fi<br />                /bin/chown sys:lp /dev/lp0<br /><br />                if ( !(lsmod | grep "^usblp" -q) ); then<br />                         insmod /lib/modules/2.6.24.4/kernel/drivers/usb/class/usblp.ko<br />                fi<br /><br />                if [ -n "`pidof cupsd`" ]; then<br />                        /usr/bin/killall cupsd 2>/dev/null<br />                fi<br />                /opt/sbin/cupsd<br />        ;;<br />        stop)<br />                if [ -n "`pidof cupsd`" ]; then<br />                        /usr/bin/killall cupsd 2>/dev/null<br />                fi<br />        ;;<br />        *)<br />                echo "Usage: (start|stop)"<br />                exit 1<br />esac<br />


Finally, do not execute and set the startup and shutdown links:



chmod +x _SK88cupsd<br />ln -s _SK88cupsd S88cupsd<br />ln -s _SK88cupsd K88cupsd<br />


Eventually, the group has yet to be created lp (if not yet
available):



addgroup lp<br />


Cups configure:



To open the file / opt / etc / cups / cupsd.conf and change
accordingly:




# Show general information in error_log.<br />LogLevel info<br />MaxLogSize 100000<br />MaxJobs 50<br />User sys<br />Group lp<br /># Allow remote access<br />Port 631<br />MaxClients 10<br /><Location /><br />  Encryption Never<br />  AuthType None<br />  Deny From All<br />  Allow From 127.0.0.1<br />  Allow From 10.0.0.0/16<br />  # Allow shared printing and remote administration...<br />  # Order allow,deny<br />  # Allow @LOCAL<br /></Location><br /><Location /printers><br />  AuthType None<br />  Order Deny,Allow<br />  Deny From None<br />  Allow From All<br /></Location><br /><Location /admin><br />  Deny From All<br />  Allow From 127.0.0.1<br />  Allow From 10.0.0.0/16<br />  # Allow remote administration...<br />  # Order allow,deny<br />  # Allow @LOCAL<br /></Location><br /># Share local printers on the local network.<br />Browsing On<br />BrowseOrder allow,deny<br />BrowseAddress @LOCAL<br /><Location /admin/conf><br />  AuthType Default<br />  Require user @SYSTEM<br />  # Allow remote access to the configuration files...<br />  # Order allow,deny<br />  # Allow @LOCAL<br /></Location>	<br />



where all the lines need to be adapted to the 10.0.0.0/16 Allow From
his own network.



Now should Cups with:



/opt/etc/init.d/S88cupsd start<br />



start without errors can and watch the master at:
http://<ip_mbwe>:631/.



Printer configuration:


NNow go to the printer's configuration in the file / opt / etc /
cups / printers my looks for the Brother HL-2030 the following measures:



<DefaultPrinter Brother_HL2030><br />	Info Brother 2030 series<br />	Location Local Printer<br />	DeviceURI parallel:/dev/lp0<br />	State Idle<br />	StateTime 1252837845<br />	Accepting Yes<br />	Shared Yes<br />	JobSheets none none<br />	QuotaPeriod 0<br />	PageLimit 0<br />	KLimit 0<br />	OpPolicy default<br />	ErrorPolicy stop-printer<br /></Printer><br />



important is the line DeviceURI parallel: / dev/lp0 that specifies where
the printer is connected.


Using the Web Interface


It is also possible to add the printer via the web interface.
To
open the web interface in the browser: http://<ip_mbwe>:631/

Administartion>
Add Printer> Enter name> Select LPD / LPR Host or Printer>
Device URI: parallel: / dev/lp0> Raw> Raw Query





Now the clients can be established:


MacOSX client:


Add In System Preferences> printer a new printer:



IP protocol and select Internet Printing Protocol - IPP



Specify the IP address MBWE and waitlist
/printers/<Druckername>



Finally, select, the driver and click the Add!



Ubuntu client:


System> System Administration> Printing> New> Network
Printer



Internet Printing Protocol specify IP address of the MBWE and
waitlist /printers/<Druckername>



Select Driver



finish



Windows XP client:


Start> Printers and Faxes> Add Printer> Next



Network printer ... > Next> Connect to a printer on the
Internet ...

http://<ip_mbwe>:631/printers/<Druckername>



next > select driver




next > finish



Windows Vista client:


Start> Devices and Printers> Add Printern



Network Printer > The printer is not listed you're looking for
> a select Share this printer as the name
enter
http://<ip_mbwe>:631/printers/<Druckername>



next > selct driver




next > finish


Tips and Tricks


If the print queue is stopped after a reboot, / should be
opt/etc/init.d/_SK88cupsd amended as follows: (Thanks to Fidatelo)



#!/bin/sh <br /># <br /># <br /># <br />case "$1" in <br />        start) <br />                if ( [ ! -c /dev/lp0 ] ) then <br />                        mknod /dev/lp0 c 180 0 <br />                fi <br />                /bin/chown sys:lp /dev/lp0 <br /><br />                if ( !(lsmod | grep "^usblp" -q) ); then <br />                         insmod /lib/modules/2.6.24.4/kernel/drivers/usb/class/usblp.ko <br />                fi <br /><br />                if [ -n "`pidof cupsd`" ]; then <br />                        /usr/bin/killall cupsd 2>/dev/null <br />                fi <br />                /opt/sbin/cupsd<br />                sleep 10<br />                /opt/sbin/cupsenable HP-Deskjet-812c<br />        ;; <br />        stop) <br />                if [ -n "`pidof cupsd`" ]; then <br />                        /usr/bin/killall cupsd 2>/dev/null <br />                fi <br />        ;; <br />        *) <br />                echo "Usage: (start|stop)" <br />                exit 1 <br />esac<br />


With the printer name is replaced with our own. After starting
cupsd to wait 10 seconds and started to join the queue.



0 Comments:

Post a Comment

<< Home