HOWTO Native Windows Printing met CUPS/Samba
Uit Gentoo Linux Wiki
Inhoud |
[bewerken] Introductie
Een printer verbinden met de parallelle of USB poort, installeer samba en cups, een beetje configuratie magie en je bent klaar om te printen in geen tijd.
Deze HOWTO overloopt alle nodige stappen om Samba en CUPS met Windows in te stellen.
Het is gebaseerd op ander werk gevonden op het Internet, forums en IRC. (De structuur van deze HOWTO is overgenomen van de HOWTO Samsung ML-1710 with Samba).
Deze gids zou voor alle printers moeten werken, maar ik zal hier de HP LaserJet 1000 gebruiker als voorbeeld. (Een moeilijkere printer trouwens vanwege de noodzaak om firmware up-te-loaden.)
[bewerken] Wat deze HOWTO inhoudt
- Een printer lokaal installeren
- De kernel configureren om het printen te ondersteunen (USB en LPT). We gebruiken een 2.6 kernel
- Samba en CUPS configureren om de printer te gebruiken in RAW mode.
- Windows clients configureren om de printer te gebruiken
[bewerken] Packages die we nodig hebben
[bewerken] Omgeving
Eerst moeten we weten welke USB host we gaan gebruiken (sla dit over als je van plan bent LPT te gebruiken). Er zijn 3 soorten USB hosts: EHCI (usb2) OHCI en UHCI. Van OHCI en UHCI heb je slechts 1 nodig (kiezen tussen een van de twee). Start het lspci programma en controleer welke USB controller je hebt:
- lspci is een onderdeel van sys-apps/pciutils
| Code: Voorbeeld 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) |
[bewerken] Kernel configuratie
Vervolgens moeten we zeker zijn dat USB (of LPT) support ondersteund wordt in de kernel. Ik verkies het compileren in de kernel tegenover het compileren als module. Deze keuze moet je zelf uitmaken.
| Linux Kernel Configuratie: options for USB |
|
Voor USB printer ondersteuning 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 Of voor LPT Device Drivers -> Character devices <*> Parallel printer support [*] Support for console on line printer |
Na het aanpassen van de configuratie en het compileren, zal je de pc moete herstarten. Herstarten is niet nodig als je de opties als module hebt gecompileerd. Een simpele modprobe zou dan al genoeg zijn.
[bewerken] Use flags
Je hebt volgende useflags nodig om de gids af te werken:
- samba - samba support voor cups
- cups - cups support voor samba
- pam - zorgt ervoor dat cups pam-authenticatie gebruikt
[bewerken] Controleer printer 'aanwezigheid'
Indien je een USB printer hebt en al ge-reboot hebt sinds het maken va de nieuwe kernel (of het laden van de modules), dan zou je de kernel moeten zien verschijnen in dmesg wanneer hij aangesloten wordt.
| Code: Run Command |
# dmesg | grep usb usb 1-2: new full speed USB device using uhci_hcd and address 4 drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x03F0 pid 0x0517 |
Als je printer herkend wordt, zoals hierboven, ga dan verder met deze HOWTO. Indien niet zal je moeten een oplossing zoeken op het hardware level.
| Note: Dit werkt enkel voor USB printers. LPT printers zijn NIET zichtbaar in dmesg |
[bewerken] Installeer de pakketten
Dit is waarschijnlijk de gemakkelijkste stap. Het is een goede oefening om altijd een pretend/verbose te doen voor je een pakket installeert. Op deze manier weet je wat er geïnstalleerd zal worden (focus op dependencies, als er al zijn). Ga ondertussen iets anders doen aangezien het ongeveer 30 minuten duurt om de pakketten te installeren, afhankelijk van de hardware/optimalisatie. Het zal langer duren als er nog dependencies moeten worden geinstalleerd.
emerge sync emerge -av hotplug samba cups
[bewerken] Configureer de Paketten
[bewerken] Configureer CUPS
Om te beginnen, pas /etc/cups/mime.convs aan en maak de commentaar ongedaan van de volgende regel, helemaal aan het einde van het bestand:
| File: /etc/cups/mime.convs |
application/octet-stream application/vnd.cups-raw 0 - |
Pas dan /etc/cups/mime.types aan en maak de commentaar ongedaan van de volgende regel, helemaal aan het einde van het bestand:
| File: /etc/cups/mime.types |
application/octet-stream |
Nu moeten we /etc/cups/printers.conf aanpassen. Verwijder alles in dit bestand en voeg het volgende toe, aangepast aan uw wensen weliswaar:
| File: /etc/cups/printers.conf |
# Je mag de voorkeur geven om http://localhost:631/ te bezoeken in plaats van dit direct aan te passen. <DefaultPrinter HPLaserJet1000> <-- Naam van de printer. Info HP LaserJet 1000 <-- De beschrijving van de printer. Location usb:/dev/usb/lp0 <-- Als je LPT gebruikt, zou het in de plaats /dev/lp0 zijn. DeviceURI usb://hp/LaserJet%201000 <-- De URI voor de printer, (INFORMATIE NODIG OVER WAT DIT ZOU MOETEN ZIJN). State Idle Accepting Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 </Printer> |
Alles wat we nu nog moeten doen is /etc/cups/cupsd.conf aanpassen. De meeste van de opties kunnen aangepast worden naar uw wensen. Het volgende moet echter steeds worden gebruikt:
| File: /etc/cups/cupsd.conf |
User lp Group lp Als je de webinterface moet aanspreken voor cups, van het subnet 192.168.1.x in dit voorbeeld, gebruik dan dit: <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> |
[bewerken] Samba Configureren
Eerst moeten er wat voorbereiding getroffen worden: Maak de directory /etc/samba/drivers/W32X86 aan, hier worden drivers neergezet die door Windows 2000 en XP computers ge-download worden.
[bewerken] The [global] service section
File to edit: /etc/samba/smb.conf
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.
| File: /etc/samba/smb.conf |
netbios name = COMPUTER_NAME workgroup = YOUR_WORKGROUP server string = Samba Server |
hosts allow is a comma-, space-, or tab-delimited set of hosts which are permitted to access a service. security affects how clients respond to Samba and is one of the most important settings in /etc/samba/smb.conf. encrypt passwords controls whether encrypted passwords will be negotiated with the client. socket options allows you to set socket options to be used when talking with the client. It is for performance fine tuning. If you find more/better options, add it to the Talk page for this article. interfaces allows you to override the default network interfaces list that Samba will use for browsing, name registration and other NBT traffic. bind interfaces allows the Samba admin to limit what interfaces on a machine will serve SMB requests.
| File: /etc/samba/smb.conf |
hosts allow = 192.168.1.0/24 127.0.0.0/8 security = user encrypt passwords = yes socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 interfaces = lo eth0 bind interfaces only = yes |
null passwords allows or disallows client access to accounts that have null (empty) passwords. hide unreadable prevents clients from seeing the existance of files that cannot be read. hide dot files controls whether files starting with a dot appear as hidden files.
| File: /etc/samba/smb.conf |
null passwords = no hide unreadable = yes hide dot files = yes |
These options should be set too:
| File: /etc/samba/smb.conf |
printcap name = cups printing = cups cups options = "raw" use client driver = no |
NOTE: The last option is particularly important; if not set, Samba and Windows negotiate a very long time about which printer driver to use - which result in a poor printing performance and can almost lock up your Windows system.
[bewerken] The [printers] service section
If a [printers] section occurs in the configuration file, users are able to connect to any printer specified in the local host's printcap file. Here, the important syntax is the last line. Additionally, path should point to samba's spool. In our case, it's /var/spool/samba.
| File: /etc/samba/smb.conf |
comment = All Printers path = /var/spool/samba browseable = no public = yes guest ok = yes writable = no printable = yes |
[bewerken] The [printername] section
Now you have to add the printer to Samba. This is done by adding a section for the printer that looks like this:
comment is the comment for the printer.
printable should be set to yes.
path the spooler directory, make one if it doesn't exists.
public set to no, so only known users of samba can use it.
guest ok same as above, just to make sure.
printer admin set to root.
| File: /etc/samba/smb.conf |
[HPLaserJet1000] comment = HP LaserJet 1000 printable = yes path = /var/spool/hplaserjet1000 public = no guest ok = no printer admin = root |
[bewerken] The [print$] service section
The [print$] section actually makes the printer available on the network. This section is for printers as [share] sections are for file shares. Additionally, path should point to samba's installed drivers. In our case, it's /etc/samba/drivers. Please note that, since we'll be using a specific file for our driver, the path below is useless but the statement is required.
| File: /etc/samba/smb.conf |
comment = Printer Drivers path = /etc/samba/drivers browseable = yes guest ok = no read only = yes write list = root |
note: Actually the path option is needed. You can place your drivers elsewhere. There will still be the OS specific directories beneath that directory.
[bewerken] Adding Samba users
WARNING: Do not add other users than root until after you have uploaded the drivers from windows. If you add a user by the same name and password as your windows user, you CANNOT login as the root user and add the driver.
I will not go into details with user management in samba. Make sure that you have added the root user to samba. (REMEMBER TO ADD THE ROOT USER).
The final step in configuring Samba is to add users.
| Code: Add Samba users |
# smbpasswd -a username |
Replace username with the login name that users log into their local Windows client. In addition, the password should also be the same. These users DO NOT need to have a real UNIX system account.
[bewerken] Services aan runlevels toevoegen
Nu moeten we enkel de cupsd en samba service aan de default runlevel toevoegen:
| Code: De services aan de default runlevel toevoegen en ze starten |
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 |
Of:
| Code: De services aan de default runlevel toevoegen en ze starten |
for x in cupsd samba hotplug ; do rc-update add $x default ; /etc/init.d/$x start ; done |
[bewerken] Uploading the printer drivers
- Download the printer driver from the vendors homepage, and extract it somewhere on your computer.
- Navigate to the print server in the Network Neighborhood, when prompted for username and password, use the root user that you added to samba in the previous section.
- Enter the printers folder.
- Right click on the printer, and click Properties.
- When it asks if you want to copy the driver, click NO .
- Now, go to the Advanced tab, and click New Driver... (If it's greyed out, you might have "use client driver" set to yes in /etc/samba/smb.conf.
- Follow the guide on screen.
Now you may add the users to samba, and customize the config to fit your needs.
[bewerken] 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 exit; fi cat /lib/firmware/sihp1000.dl > /dev/usb/lp0 |
In this case, the file is called sihp1000.dl. This is a pretty badly written script, but it works. :)
[bewerken] Resources
[bewerken] Suggested Reading
- The manpages for the different configuration files we have been editing.
- The Samba3 Official HOWTO
- Everything available on Google :)
[bewerken] Support
- Gentoo Forums
- Contact the author -- via Gentoo Forums (registration is required)
Bemerkingen of complimenten? Gelieve de Overleg sectie te gebruiken.
