This article assumes that you'll be using only one printer, that is the Netware printer. Because this procedure includes replacement of the print spooler daemon, I do NOT recommend this procedure for a working installation with one or more printers (unless of course you know what you're doing, but then you won't be reading this now would you? :) ). Also, most of the instructions are rather Redhat specific, if you are using another distribution, ask someone to translate :)
The print spooler does however do no formatting of its own. It merely stores what ever you sent it in a disk file, then send it to the printer when it becomes available. To have some kind of intelligent formating, filters are used. A print filter will determine the type of data passing through it, and peform conversions on it. This means that it doesn't matter what you send to the printer, the printer will always get something printable, usually postscript.
Filters also makes it possible to do a few nice things. Since a filter is actually nothing more than a small program that reads from stdin and writes to stdout, we can write filter programs that can do almost anything. In this case, I made it send the job to a Netware server.
Note: The location or version numbers of these software may have changed.
If you havent already done so, recompile your kernel with ipx support, but not full internal net. You may also compile ipx as a module. See the Kernel- HOWTO for more information about this.
Install ncpfs with: rpm -i ncpfs-2.0.11-3.i386.rpm (Your version number may
differ)
You may also need to install ipx-utils. Rpm will notify you if you haven't
installed ipx-utils yet.
Execute one of the following, depending on your setup. In my case the
first line worked perfectly on all of the systems I have installed this on:
You may also want to read the man pages for these commands. Since you want to print to a netware server, I assume you have access to it, and should not have a problem obtaining the correct settings here. You should also put this line in /etc/rc.d/rc.local, so that it gets executed everytime you boot your system.
You have to remove the existing lpd before installing LPRng, this is most easily acomplished with:
/etc/rc.d/init.d/lpd stop
rpm -e printtool
rpm -e rhs-printfilters
rpm -e lpr
Extract the LPRng- and magicfilter tarballs into /usr/local/src (or anywhere else you feel comfortable with), they should untar into their own subdirectories. Now follow the directions given in the README or INSTALL files of both, this usually consists of a ./configure, make, make install.
Create the directory /usr/local/printfilters and copy a suitable filter from /usr/local/src/magicfilter-1.2/filters to this directory. You may need to modify this file slightly to make it work propperly. In my case i used the psonly600-filter file: on rh5.1 a2ps was invoked with bad parameters; on rh5.0 a2ps wasn't installed and nowhere to be found on the cdrom, so i had to add this to the file:
default pipe mpage -ba4 -o -1
or install nenscript (from redhat cd) and add this line (this is probably the best option):
default pipe /usr/bin/nenscript -b -p-
Also, change these lines:
# postscript | ||
0 | %! | postscript |
0 | \004%! | postscript |
# postscript | ||
0 | %! | cat |
0 | \004%! | cat |
This is because "postscript" caused an extra clean page to be printed after every print job.
I also include this filter. It was orriginally used to print to a HP laserjet 4000.
Copy nwprint, filter and .config to /usr/local/printfilters, then edit filter and replace psonly1200-filter with the filter you intend to use.
Edit the .config file to contain the information relevant to your setup.
Now do:
chmod 755 filter nwprint chmod 640 .config chown root.daemon .config
Install the lpd startup script in /etc/rc.d/init.d. remember to do a chmod 755 /etc/rc.d/init.d/lpd.
Now you have to make symlinks to start lpd in the correct runlevels:
cd /etc/rc.d/rc3.d
ln -s ../init.d/lpd s90lpd
cd /etc/rc.d/rc5.d
ln -s ../init.d/lpd s90lpd
cd /etc/rc.d/rc6.d
ln -s ../init.d/lpd k08lpd
cd /etc/rc.d/rc0.d
ln -s ../init.d/lpd k08lpd
This should have lpd start up in the runlevels mostly used by Redhat users.
Now we get to modifying a bunch of files in /etc...
Edit /etc/printcap to look like the following:
lp:\
:sd=/var/spool/lpd/lp:\
:mx#0:\
:sh:\
:if=/usr/local/printfilters/filter:\
:af=/var/spool/lpd/lp/acct:\
:lp=/dev/null:
Edit /etc/lpd.conf and locate the line:
# Purpose: lock the IO device
# lk@
Uncomment the "lk@". This tells lpd NOT to place an exclusive lock onto the device, so if any other program tries to use /dev/null while we're printing it will not break.
Edit /etc/lpd.perms and add these lines:
REJECT NOT SERVER
REJECT SERVICE=R,P,Q,M,C,S NOT REMOTEUSER=yourusername,another,friend
This allows only the users in the comma separated list to print from the local host. I dont know what will happen if two users print at exactly the same time, but for the most part you will only allow yourself to print anyway.
Finally execute:
checkpc -f
/etc/rc.d/init.d/lpd start
Everything should work propperly now. You should now clean up /usr/local/src. Keep the tarballs in a safe place, then do this:
rm -rf /usr/local/src/magicfilter-1.2
rm -rf /usr/local/src/LPRng-3.5.1
At first I tried to make the standard Redhat print filter work with LPRng. This did not work very well, because the standard filter use files in /var/spool/lpd/lp while LPRng is rather fussy about the permisions of files in this directory. Moving the files broke everything, and as it was already 3:00 on a Saturday morning by then, I quickly got magicfilter off sunsite (We have a local mirror :) ), compiled the software and built myself a little filter script.
Now all I had to do was introduce some kind of password hiding mechanism so that users of the system cannot see the Netware username and password. I discovered that the filter was executed as the "daemon" user, therefore decided to create a .config file with permisions 640 and ownership root.daemon. This file is simply included into nwprint, but while anyone can read nwprint, no one can read .config ( except root and daemon of course :) ).
Well this allowed any user with access to the system to print, usually you would only want yourself to have access to the printer, so after reading through /etc/lpd.perms and part of the documentation, I came up with the two REJECT lines mentioned above.
1. To test the setup, change the nwprint script to cat all input to a file in /tmp. This is also nice to produce postscript files from applications that do not have the capability to save in postscript: Just uncomment the "cat > /tmp/printout.ps" line in the nwprint script. Of course you'll have to comment the nprint line out :) You can even have this installed as a second "Printer", together with your existing printer.
2. To print from pine, you have to setup lpr as default printing command rather than the other default thingy it uses.
3. Use the Generic postscript option in StarOffice. Even if you don't have a postscript printer, you should be able to use it as long as ghostscript has a driver for your printer.
4. Look in /pub/Linux/system/printing on sunsite.unc.edu for other print filters. There's plenty of existing solutions for most of the Canon bubble jet printers, as well as HP deskjets and some of the Epson printers.
Also read the Printing-HOWTO, it should be installed in /usr/doc/HOWTO but if it is not there, locate the RPM on your Redhat 5.0/5.1 CD and install it, having the howto's arround is always nice, and is in my oppinion a MUST.
If I did anything stupid or there are better ways to do this please let me know at the e-mail address below, this address should be valid at least until somewhere late in 1999 :)
Izak Burger
[email protected]