Ch 2. Setting up CUPS
CUPS is the Common Unix Printing System, we shall use this on our server to share the printer with clients. Note, here I am assuming that the printer will be connected to the Samba Server by means of either a USB or Parallel cable and not through the network.
Ch 2.1 Editing cupsd.conf
Now, like samba, cups has a configuration file, namely cupsd.conf. We shall edit the defalt cupsd.conf file as it would be difficult to start with a clean file, also there is plenty of documentation in the cupsd.conf file and if you feel brave enough, by all means enable some settings and whatnot. Below, I will show you how to edit the cupsd.conf file to get the basics running.
Firstly open the cupsd.conf file with your favourite editor:
# nano -w /etc/cups/cupsd.conf
the cupsd.conf file is fairly large, I'd suggest you edit the sections below first to get the server working, then play around with it.
MaxCopies 10 // I don't want someone accidentally wasting paper and ink on a job
MaxClients5 // Set this to whatever you like I don't want more than 5 connections to my server
BrowseAddress @IF(eth0) // change eth0 to your lan connection, just tells where to send printing updates to
BrowseAllow@IF(eth0) // only allow printing from LAN.
BrowseDenyAll // I don't want people on internet to try print using my printer
BrowseOrder deny,allow // We first stop everyone from printing, then allow only local printing.
Deny From All
Allow From 127.0.0.1 192.168.0.* // Change 192.168.0.* to address of internal network
Deny From All
Allow From 127.0.0.1 // Only the users sitting at the print server can perform admin
Now, I know that at some point people are going to print MS Office Documents, if the following lines aren't uncommented, then you are going to get some screwed up prints. Trust me, I learned the hard way...
In /etc/cups/mime.convs file, uncomment the following line, it is towards the end.
# application/octet-stream application/vnd.cups-raw 0
i.e. remove the # sign at begining of line.
Similarly, uncomment the following line in /etc/cups/mime.types:
Now, before proceeding further, we need to start cups with:
# /etc/init.d/cupsd start
Ch 2.1 Installing the Drivers
Installing the Linux drivers:
Firstly, goto the linuxprinting.org site and get the correct CUPS driver for your printer. (link)
. Download the ppd file and place it in /usr/share/cups/model.
There are 2 ways of installing the Linux driver, firstly using the command line, as root do the following:
# lpadmin -p Printer_name_used_in_Samba -E -v usb:/dev/usb/ltp0 -m Some_printer_name.ppd
The field Printer_name_used_in_Samba should be replaced with whatever you have shared your printer as. In the example smb.conf file given in Ch 1, I shared my printer as HP5160.
The field usb:/dev/usb/ltp0 is what the system refers to as the location of your printer, note this filed will vary across different systems. On some systems, when using usb printers, it could be at /dev/ultp0. If you have a parallel printer, replace usb with parallel:/dev/lpt0 or similar.
The field Some_printer_name.ppd is the name of the printer driver you have downloaded. For example, the HP Deskjet 5160 printer has a ppd file with the name HP-DeskJet_5160-hpijs.ppd.
If that method doesn't work, you can use the CUPS web interface to setup the printer. Simply launch your favourite web browser and point it to http://Name_of_Print_Server:631
. Simply point it to the location of the printer, setup its share name and tell it the correct driver to use. Note, you would need to login to this admin webpage with username as root and with your root password. Note this is your root system password and not the samba password.
Installing Windows Drivers:
You can install the drivers in one of two ways. You can either have the driver files installed on to the CUPS server, then when you add a printer on the client, it will go to that directory and fetch the drivers. Or you can install the driver as normal on each client and point it to the shared printer on the CUPS server (Note, with this method, I couldn't get it to work using HP's own drivers and had to use Adobe's drivers).
Firstly, I will explain how to set it up so that the drivers reside on the server.
At the time of writing of this howto, the CUPS Windows drivers are still under developement and hence won't be used here. Instead you have two options, either to use the Windows or Adobe Postscript drivers. Note If you have Windows clients which are pre Win 2K, you will need to use the Adobe Drivers.
Using Windows Postscript drivers
1. Make a directory in /usr/local/share/cups called "drivers"
2. Now on your windows machine, Navigate to the C:WindowsSystem32SpoolDriversW32X863 folder. Copy whatever files in this folder to a flash drive, or if your samba server is working, copy it to a share on the server.
3. Now copy whatever files which are in this directory to /usr/local/share/cups/drivers
Using Adobe Postscript drivers
1. Make a directory in /usr/share/cups called "drivers"
2. Grab yourself a copy of the Adobe postscript drivers for your language from here
. Also, get a ppd file for your printer.
3. Launch the adobe Installer and tell it to use the ppd for your printer, now the drivers will be extracted to C:WindowsSystem32SpoolDrivers folder. Copy these files to usb or a samba share on your server.
4. Copy the extracted driver files from a usb drive or samba server to /usr/local/share/cups/drivers.
Now, because we are setting it up so that the server will contain the drivers, we need add some things to the smb.conf file regarding the location of the drivers. Note the configuration below must be used for all printers
comment = Printer Drivers
path = /etc/samba/printer # this path holds the driver structure after cupsaddsmb command
guest ok = yes
browseable = yes
read only = yes
write list = root
Once that has been added, restart your samba serveice i.e:
Now, to add the drivers to samba to be shared to all clients, we execute this command:
cupsaddsmb -H Name_of_Samba_Server -U root -h Name_of_Print_Server -a
In most cases, Name_of_Samba_Server and Name_of_Print_Server are the same.
The 2nd method of installing the drivers would i.e so that drivers are on client systems is like so:
Using the printer driver which came with your printer, tell it to install as a network printer and point it to the printer which resides on the Samba server. Note, for some reason this method didn't work for me and I had to use the Adobe method outlined below:
Grab yourself a copy of the Adobe postscript drivers for your language from here
. Also, get a ppd file for your printer. Run the Adobe installer, point it to the location of the printer on the samba server. Now Under printing in the Control Panel, tell it to use this as default printer.
Ch 2.2 Client Configuration for CUPS
Windows Client configuration:
If you set it up so that driver files reside on the server, in explorer, simply navigate to the shared printer, right click on it and say "Connect", the drivers will be downloaded and you can start using it.
Otherwise simply go to the Add printer wizard in Control Panel and point it to the location of the Printer on the server. You may also want to set it as your default printer.
Linux Client Configuration (Other than the server):
Install a CUPS client on your system, usually by installing the CUPS server package, a CUPS client will also be installed. Now edit the /etc/cups/client.conf file and add the following:
And that is all there is to it. Now you should have a working file and print server.
If you want a more detailed version of the printing howto in Samba, see Kurt Pfeifle's "Printing Support in Samba 3.0 manual"
If you want more examples for setting up different configurations of a samba server, be sure to check out the official Samba by Example guide