CUPS/Samba
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
- This page is for printing from Windows clients to a Gentoo server. For printing from a Gentoo client to a Windows server, see HOWTO print winserver.
Contents |
[edit] Introduction
Connecting a printer to the parallel port or USB port, install samba and cups, a little configuration magic, and you are printing in no time.
You can print from Windows without Samba, as described here, but using Samba makes the Windows configuration idiot-proof and lets us automagically upload the latest CUPS windows drivers to the Windows box.
This HOWTO goes through all the steps needed to set up both Samba, CUPS and Windows.
It is based on different work found on the internet, the forums, and IRC. (The structure of this HOWTO is taken from the Samsung printer howto).
This guide should work for all printers, but I'll be using the HP LaserJet 1000 as an example. (It's difficult to configure, by the way, because it requires firmware uploading).
[edit] What this HOWTO will do
- Install a printer locally
- Configure your kernel to support printing (USB and LPT). We are using a 2.6 kernel.
- Configure Samba and CUPS to use the printer in RAW mode.
- Configure the Windows clients to use the printer.
[edit] Required packages
(hotplug is obsolete since udev does the magic for you....)
[edit] Environment
First we need to know what type of USB host we are using (skip this part if you are using LPT). There are two kinds of USB hosts: OHCI and UHCI. You only need one of them. Run the lspci utility and check what type of USB controller you have:
| Code: sample lspci output |
# lspci 0000:00:00.0 Host bridge: VIA Technologies, Inc. VT82C693A/694x [Apollo PRO133x] (rev c4) 0000:00:01.0 PCI bridge: VIA Technologies, Inc. VT82C598/694x [Apollo MVP3/Pro133x AGP] 0000:00:04.0 ISA bridge: VIA Technologies, Inc. VT82C686 [Apollo Super South] (rev 40) 0000:00:04.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06) 0000:00:04.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 16) 0000:00:04.3 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 16) 0000:00:04.4 Host bridge: VIA Technologies, Inc. VT82C686 [Apollo Super ACPI] (rev 40) 0000:00:09.0 SCSI storage controller: Adaptec AHA-2940/2940W / AIC-7871 0000:00:0b.0 Ethernet controller: 3Com Corporation 3c900B-Combo Etherlink XL [Cyclone] (rev 04) 0000:00:0c.0 VGA compatible controller: S3 Inc. 86c325 [ViRGE] (rev 06) 0000:00:0d.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10) |
[edit] Kernel configuration
Next, you will need to make sure USB (or LPT) support is compiled into your kernel. I prefer compiling support into my kernel as opposed to making modules. The choice is yours.
| Linux Kernel Configuration: options for USB |
|
For USB print support Device Drivers -> USB Support <*> Support for Host-side USB <*> EHCI HCD (USB 2.0) support [ ] Full speed ISO transactions (EXPERIMENTAL) [ ] Root Hub Transaction Translators (EXPERIMENTAL) < > OHCI HCD support <*> UHCI HCD (most Intel and VIA) support <*> USB Printer support Or for LPT Device Drivers -> Character devices <*> Parallel printer support |
After making your changes, you will need to reboot if you compiled USB support into the kernel. Otherwise, you could just load the modules. I would suggest rebooting, though.
[edit] Use flags
You need three useflags to be set for this guide:
- samba - adds samba support to cups
- cups - adds cups support to samba
- pam - makes cups use PAM for authentication.
[edit] Install Packages
This is probably the easiest step. It is good practice to always do a pretend/verbose before installing any package. This way you know what is going to be installed (focusing on dependencies, if any). Kick back for a while as it takes about 30 minutes to install the packages, depending on hardware/optimizations. It will take longer if any dependencies need to be installed.
emerge --sync emerge -av hotplug samba cups
[edit] Configuring packages
[edit] Configuring CUPS
First, edit /etc/cups/mime.convs and uncomment the following line at the very bottom of the file:
| File: /etc/cups/mime.convs |
application/octet-stream application/vnd.cups-raw 0 - |
Then edit /etc/cups/mime.types and uncomment the following line at the very bottom of the file:
| File: /etc/cups/mime.types |
application/octet-stream |
Now we need to edit /etc/cups/printers.conf, remove everything in it, and add the following, modifying it for your needs:
| File: /etc/cups/printers.conf |
# You may prefer to visit http://localhost:631/ rather than edit this directly. <DefaultPrinter HPLaserJet1000> <-- Name of the printer. Info HP LaserJet 1000 <-- The Description of the printer. Location usb:/dev/usb/lp0 <-- This is a human readable string, stating the Location (eg. "my Brother's Office Plotter") DeviceURI usb://hp/LaserJet%201000 <-- the URI for the printer, ("usb" is the name of the backend, doing the actual transfer to the printer ). State Idle Accepting Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 </Printer> |
All we need to do now is edit /etc/cups/cupsd.conf. Most of the options can be changed as you like. The following should be set, though:
| File: /etc/cups/cupsd.conf |
User lp Group lp If you need to access the web interface for cups, from the subnet 192.168.1.x in this example, use this: <Location /> Order Deny,Allow Deny From All Allow From 192.168.1.* </Location> <Location /admin> AuthType Basic AuthClass System Order Deny,Allow Deny From All Allow From 192.168.1.* </Location>
<Location /> Order Deny,Allow Deny From All Allow From 127.0.0.* </Location> <Location /admin> AuthType Basic AuthClass System Order Deny,Allow Deny From All Allow From 127.0.0.* </Location> |
[edit] Configuring Samba
First, you need to do a few things: Create the folder where the drivers for the Windows 2000/XP workstations to download will be placed:
# mkdir -p /usr/share/cups/drivers
Next create a folder that we will use to transfer some files from your Windows box:
# mkdir -m 777 /home/shared-folder
Now create /etc/samba/smb.conf and paste in the following:
| File: /etc/samba/smb.conf |
[global]
workgroup = MSHOME
netbios name = mini-itx
server string = file and printer server
hosts allow = 192.168.1.
security = user
load printers = yes
printing = cups
printcap name = cups
use client driver = no
[share]
path = /home/shared-folder
comment = shared files
read only = no
browseable = yes
guest ok = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = yes
printable = yes
writable = no
guest ok = yes
[print$]
comment = Printer Drivers
path = /usr/share/cups/drivers
browseable = yes
guest ok = yes
read only = yes
write list = root
|
You should edit the following to suit your needs:
netbios name sets the NetBIOS name by which a Samba server is known. This is what you will see in network neighborhood.
workgroup controls what workgroup your server will appear to be in when queried by clients.
server string controls what string will show up in the printer comment box in print manager and next to the IPC connection in net view.
hosts allow is a comma-, space-, or tab-delimited set of hosts which are permitted to access a service. To allow everyone on your LAN, use your current IP minus the last number.
security If you use "users", only user accounts you specify will be allowed. For a completely open system you can change this to "share", but for now you MUST leave it set to "user" or you will have problems during a later step.
[edit] Adding services to runlevels
Now we just need to add the cupsd and samba services to the default runlevel, if you have a recent version of udev, you can skip the hotplug stuff:
| Code: Adding the services to the default runlevel and starting them |
rc-update add cupsd default rc-update add samba default rc-update add hotplug boot /etc/init.d/cupsd start /etc/init.d/samba start /etc/init.d/hotplug start |
Or:
| Code: Adding the services to the default runlevel and starting them |
for x in cupsd samba hotplug ; do rc-update add $x default ; /etc/init.d/$x start ; done |
[edit] Prepare the Windows Driver
When a Windows box uses our print server for the first time, we want the necessary drivers to be automatically downloaded from our server and installed. Download the CUPS Windows drivers; these work with the existing Windows PostScript drivers and add some additional functionality. Current file as of June 1, 2008 is cups-windows-6.0-source.tar.gz .
# cd ~ # wget ftp://ftp.easysw.com/pub/cups/windows/cups-windows-6.0-source.tar.gz
Now extract the archive, enter the new directory, and install:
# tar -xzf cups-windows-6.0-source.tar.gz # cd cups-windows-6.0 # make install
This will create /usr/share/cups/drivers and copy in cups6.inf, cups6.ini, cupsps6.dll, and cupsui6.dll. Now we have half of the driver files that we need, but we have to get the rest off of a Windows 2000/XP box. First, we have to add some Samba users, so we can access our shared folder from the Windows box:
# smbpasswd -a root # smbpasswd -a <a_valid_username>
Note that smbpasswd requires valid system usernames that already exist in /etc/passwd.
Now log-on to your Windows Box and run explorer.exe. In the Address bar, type \\mini-itx , but substitute your server's netbios name for "mini-itx". Enter your username and password, then you should see a folder named share -- we are going to copy the files we need into that folder. (If you have trouble with this step, try entering the server's IP address instead of netbios name.) Go to \WINDOWS\system32\spool\drivers\w32x86\3 and copy ps5ui.dll, pscript5.dll, pscript.hlp, and pscript.ntf into the share folder. If the filenames are upper-case, then you have to rename them so they are all lower-case. If the files are missing, you can get them from Adobe.
Now, back on the server, copy those four files from /home/shared-folder to /usr/share/cups/drivers/ .
# cp /home/shared-folder/ps* /usr/share/cups/drivers/
We now will export the printers to samba:
# cupsaddsmb -H localhost -U root -a
This will export all known printers; see the cupsaddsmb man page if your requirements are different.
You should now be able to use the printer from any Windows box. You can double click on the printer in "My Network Places" or use the "Add Printer" wizard. The easiest way is to run explorer.exe, use the folder-tree view, and go to My Network Places >> Entire Network >> Microsoft Windows Network >> Mshome Now you should see your printer, so double-click on it and you're ready to print. You should NOT have to manually select or install drivers.
If you want to make your Samba server open to everyone with access to the network, you can now change /etc/samba/smb.conf so security = share .
[edit] Uploading the firmware to the printer upon insertion
If your printer requires you to upload the firmware to it everytime you plug it in, this might be helpful to you. First, copy the firmware file (typically placed inside the driver file you download from the vendor website and extracted) to /lib/firmware.
Now, go to the /etc/dev.d/default directory and make a script called hotplug.dev, and put execution permissions on it:
| Code: hotplug.dev |
#!/bin/sh if [ "$DEVNAME" == "/dev/usb/lp0" ] then cat /lib/firmware/sihp1000.dl > /dev/usb/lp0 else exit 1 fi |
In this case, the file is called sihp1000.dl.
This is a pretty badly written script nice script, but it works. :)
[edit] Resources
[edit] Suggested Reading
- The manpages for the different configuration files we have been editing.
- The manpage for cupsaddsmb
- http://localhost:631/help/
- The Samba3 Official HOWTO
- Everything available on Google :)
- Useful guide on the Gentoo forums
[edit] Support
- Gentoo Forums
- Contact the author -- via Gentoo Forums (registration is required)
