牛人论坛

 找回密码
 注册
搜索
查看: 7559|回复: 0

OpenWrt 路由器做打印服务器和扫描服务器

[复制链接]
发表于 2012-2-10 14:07:07 | 显示全部楼层 |阅读模式

CPUS Printer Server Configuration


CUPS is better than p910nd to make a router, a Buffalo 802.11n Gigabit router WHR-HP-300NH, for instance, to be a perfect network printer server, working with almost any USB printer.

However, there is no satisfying document to make it clear how to do this. Now here is what I did to make my Canon MX300 to work without a problem.

First of all, USB module should be ready, ohci_hcd, ehci_hcd, usbcore should be running.

Then make sure kmod-usb-printer is NOT installed and running. This is critical, for CUPS doesn’t rely on kernel module to talk to USB printers.

Now install CUPS, which is a single packet on Backfire,

opkg install cups

Before you start to configure your printer via http://router-ip:631, there is a little configuration to be done.

In /etc/cups/cupsd.conf

change
User Nobody
Group Nobody

to:
user root
Groupd root

And change AuthClass to AuthClass Anonymous

Then, change ACL on /usr/lib/cups/backend/usb to 700 (chmod 700 /usr/lib/cups/backend/usb). This changes the behaviour of cups, which normally tries to execute the backend through a user account other than root. This forces the backend to run as root from cups.

Remember to change allowed network to your network,  otherwise you won’t be able to find the printer.

Now you should be able to run /usr/lib/cups/backend/usb to check if your printer is recognized correctly.

If all good, go to http://your-router-ip:631/admin to add a printer, remember to click on sharing to share this printer online.

Then, copy the link URL of the printer(right click on the printer), on any client PC, use the link to add a network printer, specify the printer type, it should work.

Remember, CUPS use /tmp/cups/ folder as the spool, which on a router running OpenWrt backfire, is a RAM folder. My Buffalo WHR-HP-300NH has 64M memory, and /tmp is about 28M bytes. This size of spool is not ideal for heavy duty office printing, but should be OK for home use. If it is intended for office printing, I suggest you install a USB memory stick and use it as the spool.

Saned Configuration

To make your router a network scanner server providing sharing, you need SANE package on OpenWrt.

Try to install xinet, sane-backends, sane-frontends and sane-libs first. SANE is not going to run all the time, we usually use xinetd to bring up SANE whenever there is a request to scan from the network.

But use scanimage to check if your scanner is recognized or not:

scanimage -L

My Canon MX300 is recognized without a problem.

Then, create file /etc/services, and put following line in it:

sane       6566/tcp

Also, create file /etc/xinetd.d/sane and put following lines in it:

root@Buffalo:~# cat /etc/xinetd.d/sane,
service sane
{
port            = 6566
socket_type     = stream
wait            = no
server          = /usr/sbin/saned
user            = root
group           = root
}

The content of these two files are quite obvious, xinetd needs it to run properly.

Then run /etc/init.d/xinetd enable to put a run-at-start script under /etc/rc.d/ as something like S50xinetd.

Now you can bring up xinetd by running /etc/init.d/xinetd start.

If it doesn’t start. try to run xinetd -d (debug mode) to find out why.

Remember to have /etc/hosts with you router hostname in, and allow the network segment in /etc/sane.d/saned.conf.

So far the server is ready. You will need client on your PC to access the network scanner.

The perfect client is SaneTwain from http://sanetwain.ozuzo.net/.

You can run it as a standalone client, or you can put the sanetwain.ds file in your c:\windows\system32\twain_32 folder, and use any photo processing software, picasa, for instance, to import pictures from the network scanner.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|新人网

GMT+10, 2014-8-21 20:08 , Processed in 0.119080 second(s), 16 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表