|
Whole document tree 12.18. Using Programs To Get Printcap InformationIn the lpd.conf file you can specify: This will cause the LPRng software to execute the specified program, which should then provide the printcap information. The program is invoked with the standard filter options, and has the name of the printcap entry provided on STDIN. The filter should supply the printcap information on stdout and exit with a 0 (success) error code. By convention, the printcap name 'all' requests a printcap entry that lists all printers.This technique has been used to interface to the Sun Microsystem NIS and NIS+ databases with great success. By having the invoked program a simple shell script or front end to the nismatch or ypmatch programs, the complexity of incorporating vendor specific code is avoided. 12.18.1. How to use NIS and LPRngThis note is based on material sent to the lprng@lprng.com mailing list by Paul Haldane <paul@ucs.ed.ac.uk>. We generally don't use NIS for printcap files (we've moved to hesiod) but I can show you what we've done in the past. The input to NIS is a normal printcap file:
# Classical printcap entry
lp23a|lp23|lp|main printhost printer - KB, EUCS front Door:\
:lp=lp23a@printhost:\
:sd=/var/spool/lpr/lp23a:
#lprng printcap entry
lplabel|lpl|TEST - Labels printer:
:lp=:rm=printhost:rp=lplabel:
:sd=/var/spool/lpr/lplabel:
:rg=lpadm:mx=1:
To build the NIS printcap.byname map we add the following to the NIS makefile (along the other bits and pieces that the makefile needs to know about a new map).
PRINTCAP=${sysconfdir}/printcap
# warning : [ ] is actually [<space><tab>] in the script
printcap.time: $(PRINTCAP) Makefile
if [ -f $(PRINTCAP) ]; then \
sed < $(PRINTCAP) \
-e 's/[ ][ ]*$$//' -e '/\\$$/s/\\$$/ /' \
| awk '$$1 ~ /^#/{next;} $$1 ~ /^[:|]/ {printf "%s", $$0; next;} \
{printf "\n%s", $$0 }' \
| sed -e 's/[ ]*:[ ]*:/:/g' -e 's/[ ]*|[ ]*/|/g' \
-e '/^[ ]*$$/d' > .printcap.$$$$; \
cat .printcap.$$$$; \
if [ $$? = 0 -a -s .printcap.$$$$ ]; then \
awk <.printcap.$$$$ '{ FS=":"; OFS="\t"; } { \
n = split($$1, names, "|"); \
for (i=1; i<=n; i++) \
if (length(names[i]) > 0 \
&& names[i] !~ /[ \t]/) \
print names[i], $$0; \
}' | $(MAKEDBM) - $(YPDBDIR)/$(DOM)/printcap.byname; \
awk <.printcap.$$$$ '{ FS=":"; OFS="\t"; } { \
n = split($$1, names, "|"); \
if (n && length(names[1]) > 0 && names[1] !~ /[ \t]/) \
print names[1], $$0; \
}' | $(MAKEDBM) - $(YPDBDIR)/$(DOM)/printcap.bykey; \
rm -f .printcap.$$$$; \
touch printcap.time; echo "updated printcap"; \
fi \
fi
@if [ ! $(NOPUSH) -a -f $(PRINTCAP) ]; then \
$(YPPUSH) printcap.byname; \
$(YPPUSH) printcap.bykey; \
touch printcap.time; echo "pushed printcap"; \
fi
To specify that you want YP database rather than file access, use the following entry in your /etc/lpd.conf file: Put the following shell script in /usr/local/libexec/pcfilter
#!/bin/sh
#/usr/local/libexec/filters/pcfilter
read key
# specify the full pathname to the ypmatch program
# the location depends on the version of Solaris or your
# system install
/full/pathname/to/ypmatch "$key" printcap.byname
You can test this by using: 12.18.2. How to use NIS and LPRng - Sven Rudolph
Date: Wed, 11 Sep 1996 00:11:02 +0200
From: Sven Rudolph <sr1@os.inf.tu-dresden.de>
To: lprng@lprng.com
Subject: Using :oh=server: with NIS
When I use a cluster-wide printcap, I want the entries for each printer to appear, e.g.:
---------- start of printcap snippet
lp1
:lp=lp1@server
lp2
:lp=lp2@server
lp1
:server:oh=servername
:sd=/var/spool/lpd/lp1
:lp=/dev/lp1
:mx=0
---------- end of printcap snippet
When I create a NIS map out of this the printer name is used as a key and must be unique. The NIS makedbm will drop all but the last entry for each printer. This makes the printer on the clients unavailable. I solved this by a hack where the second entry is called lp1.server and the NIS client script has to request the right entry.
|