* [9fans] lp improvements
@ 2003-04-17 3:07 Geoff Collyer
0 siblings, 0 replies; only message in thread
From: Geoff Collyer @ 2003-04-17 3:07 UTC (permalink / raw)
To: 9fans
Since Plan 9 systems at a site typically share a file server, I've
modified lp to not send jobs (via port 515) to the machine responsible
for the printer, just to enqueue the job, but rather to just put the
job in the spooler queue and start the appropriate dæmon or kick the
responsible machine to start the dæmon. (It's still possible to
queue jobs on non-plan-9 systems using non-generic daemon or spooler
scripts in the devices file.)
I've made the last field ("FIFO") of /sys/lib/lp/devices optional. If
omitted, it now defaults to "generic". In /sys/lib/lp/spooler, smart
is my improved version of generic. You could copy or rename it to
generic, but I wanted to avoid at least that one replica conflict.
: cpu; cat /sys/lib/lp/devices
# device_name loc dest_host phys_dev_name speed class def_proc spooler stat kill daemon sched
foo home cpu.collyer.net foo.collyer.net - post+HPJCL+nohead+300dpi generic smart hp generic hp
; history -D lp
Apr 12 21:23:25 PDT 2003 lp 5454 [geoff]
lp:137,138 d /n/dump/2003/0412/rc/bin/lp:136
<
< # parse devices
lp:155,159 d /n/dump/2003/0412/rc/bin/lp:152
<
< # supply defaults
< if (~ $#SCHED 0 || ~ $SCHED '')
< SCHED=generic # was FIFO
<
# To unbundle, cd to /sys/lib/lp and run the rest of this file
echo sched/generic
sed 's/^X//' >sched/generic <<'!'
X#!/bin/rc
ls -ptr $* | sed -n -e '/^[^.].*\.[0-9][0-9]*\.[1-9][0-9]*$/p'
!
echo spooler/smart
sed 's/^X//' >spooler/smart <<'!'
X#!/bin/rc
X# a smarter version of the `generic' spooler.
X# all our Plan 9 systems share a common file system, thus a common lp spool.
X# so stop this crazy business of sending jobs around via port 515;
X# just stick the job in the queue and kick the guy who runs the printer.
rfork en
if (! ~ $DEBUG '')
X flag x +
pfx=`{echo $LPMACHID | sed 's/\..*//'}^.$pid
qdir=$LPSPOOL/$LPDEST
X{ mkdir $qdir && chmod 777 $qdir } >[2]/dev/null
X# Process and enqueue files to be printed. take arguments as input files.
i=0
if (~ $#* 0)
X * = /fd/0
for (f) {
X i = `{echo $i + 1 | hoc}
X # check access to the file so that you know that a failure in the
X # processing is a drastic error which will cause an exit from lp.
X if (! test -r $f)
X echo $f: not readable or missing >[1=2]
X if not {
X job=$pfx.$i
X @ {
X rfork n
X bind -b $LPLIB/process /bin
X $LPPROC
X } <$f >$qdir/.$job # temporary name
X if (~ $status '') @ {
X cd $qdir
X echo $LPMACHID $LPUSERID $job 0 >$job^id
X mv .$job $job # convert to real name
X }
X if not {
X rm -f $qdir/.$job
X exit 'preprocessing failed'
X }
X }
X}
X# kick remote daemon if needed; lp -R just runs the daemon
if (! ~ $THIS_HOST $DEST_HOST && ! ~ $DAEMON -)
X rx $DEST_HOST 'LPDEST='^$LPDEST^' lp -R'
X# lp will start the appropriate daemon (not lpdaemon) locally when we return
exit ''
!
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-04-17 3:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-17 3:07 [9fans] lp improvements Geoff Collyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).