This whole ordeal began when my wife's Windows 98 machine began to die. All along, that machine had been the only machine on our home network with printer access. I decided that it was time for me to turn my trusty linux machine into a print server for both Linux and Windows clients on my home network. This is how I did it.
To start, I did some research on printing for Linux. As with many aspects of Linux, there are lots of options in the area (see www.linuxprinting.org for more information). However, I needed a solution that would work for both my Linux workstation and my Windows clients. Based on the information that I gathered, I decided that the combination of CUPS (the Common Unix Printing System www.cups.org) and the latest version of Samba (www.samba.org) would be the best combination.
As it turns out, RedHat 7.1 doesn't include CUPS, and ships with an older version of samba (ships with v2.0.10, I wanted v2.2.1). In addition, RedHat does include another of the Linux printing systems (LPRng) that I had decided not to use.
UPDATE: As of RedHat 7.3, RedHat linux now does come with CUPS support as well as both the gimp-print and foomatic print drivers. It also includes a recent version of Samba, so there is no additional software to install. All you have to do is configure Cups and Samba according to the instructions below and you should be good to go!So to get things ready for the installation, I decided to remove all of the packages involved in printing and samba. As root, I performed the following commands:
> rpm -e LPRng printtool samba samba-common samba-client
Next, it was time to download some of the new packages that I would need. This includes the latest version of samba (now v2.2.4), the latest version of CUPS (v1.1.15). I downloaded all of these as binary RPMs. The samba and cups ackages I located on rpmfind.net. Again, if you are running RedHat Linux 7.3, there is no need to install new software.
http://rpmfind.net/linux/rpm2html/search.php?query=cups - Grab the source RPM and build the RPMs yourself.
http://rpmfind.net/linux/rpm2html/search.php?query=samba - Again, grab the source RPM and buil the binary RPM yourself.
After reading through the CUPS documentation, I decided that I needed a good printer driver for the HP DeskJet 870Cse. Upon further searching (see http://www.ebbs.com.au/~mark/cups-gimp-print.html), I discovered that the gimp-print project has just the drivers I was looking for (in release v4.1.99a). They do not distribute RPMs, but you can find them on rpmfind.net or build and install from source. To download it, I did the following:
http://rpmfind.net/linux/rpm2html/search.php?query=cups-drivers
First, I installed the samba and cups source RPMs using the following commands. After building the binary RPMs, I then installed those:
> rpm -Uvh samba* cups*
> cd /usr/src/redhat/SPECS
> rpm -bb cups.spec
> rpm -bb cups-drivers.spec
> rpm -bb samba.spec
> cd ../RPMS/i386
> rpm -Uvh cups* samba*
I then decided it was time to hook up the printer to my Linux machine. It is a paralell-port printer, and it occured to me that some time ago, I had disabled the paralell port modules in my kernel becuase I never thought I would need them. Oops. I am running Linux 2.4.4, and so I needed to do a quick kernel reconfiguration in order to get my paralell port working.
To begin this exercise in kernel reconfiguration, I ran the kernel X configurator:
> cd /usr/src/linux-2.4.4/
> make xconfig
This will bring up the kernel X config window. As it turns out, there are a few important items that need to be built. I like the modular approach, so I configured my kernel for each of the following to be built as modules (M):
Paralell Port Support
Paralell port support
PC-Style hardware
Character Devices
Paralell printer support
Support for User-Space paralell port device drivers
I then pressed the "Save and Exit" button, and issued the following command build and install the new modules for me:
> cd /usr/src/linux-2.4.4/
> make dep clean install modules modules_install
Because I was already running v2.4.4 of the kernel, there was no need to reboot my machine before using the new modules. In order to load the modules, I issued the following commands (which I later incorporated into the rc.local startup script):
> insmod parport
> insmod parport_pc
> insmod lp
> insmod ppdev
Although I'm not sure if it is strictly necessary, the kernel docs on paralell ports told me to add the line 'alias parport_lowlevel parport_pc' to the /etc/modules.conf file. So I did.
These commands went off without a hitch. It was now time to restart CUPS (to make sure it sees the new printer drivers and the paralell port). To restart CUPS, I issued the following commands, using the init.d script that was created when the CUPS RPM was installed:
> /etc/init.d/cups restartI then pointed my favorite web-browser at http://localhost:631/, which is the port for the CUPS web-based administration tool, which is VERY slick. I clicked the 'Manage Printers' link, which brought me to the Manage Printers page. At the bottom of the page there was an 'Add Printer' button. I clicked it. I was first asked to login, where I used username 'root' and the root password. On the next page, I entered in a printer name, location and description. I used 'HP_DeskJet_870Cse' as the name, 'Home' as the location, and 'HPDJ 870Cse' as the description. I then pressed the continue button.
On the page that followed, I was asked for the connection that would be used to talk to the printer. I chose 'Paralell Port #1' from the pull-down menu. After pressing continue, I was presented with a list of manufacturers to choose from. I selected 'HP' and pressed continue. On the next page, I selected the gnome-print CUPS driver for 'DeskJet 870C'. If you get lost, read the CUPS documentation, which is quite good. And the web-based administration makes most things easy to figure out anyways.
Once I had the printer configured in CUPS, I printed the test page (this feature is accessed from the Manage Printers page). The test page printed successfully, which meant that printing was now setup and configured for my Linux machine.
Now, for Windows 2000
I had previously been using Samba to share files from my Linux machine to the Windows machines on my network, but I had never used Samba for printing before. As per the instructions above, I now have samba v2.2.1 installed. This version of Samba has direct support for CUPS-style printing, and the default samba configuration file (/etc/samba/smb.conf) that is installed by the Mandrake RPMs gets you very close right out of the box (because CUPS is the default printing system used by Mandrake).
I'll spare you all the sordid details, and just show you what my /etc/samba/smb.conf file looks like, and then explain some of the entries below:
[global]
workgroup = BUBEREL.ORG
netbios name = TAYLOR
server string = Buberel File Server
hosts allow = 192.168.1. 127.
guest account = nobody
log file = /var/log/samba/log.%m
max log size = 50
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
username map = /etc/samba/smbusers
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
interfaces = 192.168.1.1/24
printcap name = lpstat
printing = cups
[printers] comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = yes
writable = no
printable = yes
create mode = 0700
print command = lpr -P %p -o raw %s -r
lpq command = lpstat -o %p
lprm command = cancel %p-%j
As you can see, I use user-based security (security = user). I dont' think this is vital to making printing work, but you can read all about how to do it in the Samba HOWTO sections 2.3 and 2.4 (http://us4.samba.org/samba/docs/Samba-HOWTO-Collection.html)
The important parts include the 'printing = cups' and 'printcap name = lpstat' line from the [global] section. This tells samba how to get the list of available printers that Windows users will be able to use. The other really important lines are in the [printers] section. The print, lpq and lprm commands tell samba which commands to use to print, view the contents of the print queue, and how to cancel a print job from a Window client. These are all utilities supplied by the CUPS installation.
IMPORTANT NOTE: It is possible to setup samba v2.2 to allow Windows clients to download and install their print drivers directly from the server. The configuration shown here does not accomplish that.
I then configured my Windows 2000 machine to belong to the workgroup 'BUBEREL.ORG'. Next, I ran the Add Printer Wizard (Desktop -> Add Printer -> Network), and selected my Linux server as the host. In the list my 'HP_DeskJet_870Cse' appeared. I selected that printer. Then Windows complained that 'The print server is not configured to install the correct printer driver. Press OK to select the print driver from a list' (or something like that). I pressed 'OK'. Windows then showed me the list of available printer drivers. I selected the HP DeskJet 870Cse driver, and everything was installed.
Lastly, a note about your system startup scripts: In order for Samba to recognize that CUPS is available as a printing system, the cups daemon must be up and running before you start your sabma daemon. On RedHat 7.3, the startup order is Samba first, then CUPS. You should change this around so that cups starts before samba. This can be done by using the 'chkconfig' tool.
And that's it. You're done. Print a test page and go to bed. The world is good now.