[原创]在嵌入式NAS上实现打印服务器

内核编译和嵌入式产品的设计与开发
回复
embedded_nas
帖子: 5
注册时间: 2008-09-09 0:03

[原创]在嵌入式NAS上实现打印服务器

#1

帖子 embedded_nas » 2008-09-15 23:28

1. 介绍

在SOHO和中小企业中,文件和打印共享是常用的一个功能。文档《Samba — Linux下的网络邻居》(1)介绍了如何在NAS1200(2)上安装Samba(3)实现文件共享,接下来在这篇文章中,我们将利用HP Deskjet 3748(4)打印机作为例子,介绍如何在NAS1200上安装打印机驱动程序,以及如何用Samba实现打印共享。


2. 安装打印机驱动程序

注意:在安装打印驱动程序之前,不要把打印机和NAS1200连接。

NAS1200的操作系统是Debian Linux 4.0(5),我们首先要用apt-get命令安装以下软件包:
apt-get install cupsys cupsys-client libcupsys2-dev cupsys-bsd libdbus-1-dev g++ gs-esp libssl-dev libjpeg62-dev libsnmp-dev libc6 libtool libusb-dev make python-imaging python-qt3 python-dbus python-dev python python python-reportlab libsane libsane-dev sane-utils sane

安装完以上软件包后,就要去HP的官方网站下载HP Deskjet 3748的打印机驱动程序。Linux版的HP打印机驱动程序叫做HPLIP(6) (HP Linux Imaging and Printing)。HPLIP支持HP的大多数打印机型号,目前的最新版本是2.8.7,可从http://hplip.sourceforge.net下载。用下面的命令下载并运行HPLIP (运行HPLIP时不要用超级用户权限)。
wget http://prdownloads.sourceforge.net/hpli ... -2.8.7.run
sh hplip-2.8.7.run

运行hplip-2.8.7.run时,会出现一系列交互式提示,可按照以下输入:
Please choose the installation mode (a=automatic*, c=custom, q=quit) : a
Is "Debian 4.0" your correct distro/OS and version (y=yes*, n=no, q=quit) ? y
Would you like to enable support for parallel (LPT:) connected printers? (y=yes, n=no*, q=quit) ? n
Please enter the root/superuser password: 输入root的密码
Please read the installation notes. Press <enter> to continue or 'q' to quit: 直接按回车
Restart or re-plug in your printer (r=restart, p=re-plug in*, i=ignore/continue, q=quit) : q

HPLIP的安装过程比较长,在安装时可以打开另外一个终端窗口,用tail命令查看安装进度,例如:
tail –f hplip-2.8.7/hplip-install_Mon-15-Sep-2008_16:23:11.log
这里Mon-15-Sep-2008_16:23:11表示log文件创建的时间。

HPLIP安装完毕后,用shutdown命令关闭NAS1200,例如:
shutdown –h now

等待shutdown命令执行完毕,关掉NAS1200的电源开关,然后连接打印机到NAS1200的USB口,并打开打印机电源,然后再打开NAS1200的电源。

等待NAS1200启动完毕,进入超级用户权限,执行命令:
hp-setup

然后按照下面提示输入打印机的配置信息,如果输入正确的话,打印机最后会打印一幅测试页,这就说明打印机在本地的安装成功了。
--------------------------
| CHOOSE CONNECTION TYPE |
--------------------------
Num. Connection Connection Type Description
Type
---------- ---------- ----------------------------------------
0* usb Universal Serial Bus (USB)
1 net Network/Ethernet/Wireless (direct
connection or JetDirect)
Enter number 0...1 for connection type (q=quit, enter=usb*) ? 0

Please enter a name for this print queue (m=use model name:'Deskjet_3740'*, q=quit) ? m

Found a possible PPD file: hpijs/HP/hp-deskjet_3740-hpijs.ppd.gz
Desc: HP Deskjet 3740 Foomatic/hpijs, hpijs 2.8.7.4
Note: The model number may vary slightly from the actual model number on the device.
Does this PPD file appear to be the correct one (y=yes*, n=no, q=quit) ? y

Enter a location description for this printer (q=quit) ?NAS1200

Enter additonal information or notes for this printer (q=quit) ? 直接按回车

Would you like to print a test page (y=yes*, n=no, q=quit) ? y


3. 配置Samba

在文档《Samba — Linux下的网络邻居》中我们已经介绍了Samba的安装和配置,这里要做的是增加Samba对打印共享的支持。

用文本编辑器打开/etc/samba/smb.conf,修改[global], [printers]和[print$]三个部分的配置,如下所示:

[global]
# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
load printers = yes
# CUPS printing. See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
printing = cups
printcap name = cups

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
public = yes
writable = no
create mode = 0700

[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = yes

修改完后,重新启动NAS1200,就可以在Windows主机的网络邻居中看到打印机了,如下图所示:



4. 配置Windows主机

从HP的官方网站(http://www.hp.com)下载HP Deskjet 3748的Windows驱动程序,例如Windows XP的驱动程序名为3740_enu_win2k_xp.exe,双击该文件解压它(这里只需要解压,不用安装)。

然后用网络邻居打开NAS1200(如上图所示),双击图中的Deskjet_3740图标,这时Windows就会提示安装HP Deskjet 3748的驱动程序。按照提示,指定驱动程序的路径(即3740_enu_win2k_xp.exe的解压路径)。

至此,所有步骤安装完毕,Windows主机可以使用NAS1200上共享的打印机了。


5. 参考资料

(1) 《Samba — Linux下的网络邻居》,http://www.eracore.com/support/samba.pdf
(2) NAS1200产品中文主页:http://www.eracore.com/products/nas1200_cn.html
(3) Samba官方网站:http://www.samba.org
(4) HP Deskjet 3748官方网站:http://www.hp.com
(5) Debian Linux官方网站:http://www.debian.org
(6) HPLIP官方网站:http://hplip.sourceforge.net





有关产品的更多信息,请访问Eracore Technologies的官方网站http://www.eracore.com,或者请联系support@eracore.com
回复