[Wylug-help] Moderated Print Server

Gary Stainburn gary.stainburn at ringways.co.uk
Fri, 21 Feb 2003 11:21:10 +0000


On Friday 21 Feb 2003 10:17 am, Ian Rutson wrote:
> I have a dream......

Hmmm, I can't even afford one of those.

>
> Ok, so that's a bit melodramatic, but I know what I want, I just don't know
> how to do it.  With the kids growing up and starting to use computers more
> and more, I have built them one, which they love, however, they also love
> the printer, especially printing 20,000 copies of their latest creation.  I
> have a Mac running debian which I use as a 'playing' box, main role running
> apache.  Here is the ideal, is it possible:
>
> Set up samba on Debian box to run as print server (this bit should be no
> problem), but I would like it to be 'moderated'.  A print job comes in from
> my PC, it prints.  A print job comes in from their PC, it is stored pending
> approval from myself or my wife.  What would be really nice would be a PHP
> or similar interface to this with thumbnails of the print jobs and
> approve/deny buttons.
>
> Currently their machine is running Win98, but is going to XP soon, what
> would be REALLY nice, would be to have separate accounts on their PC, so if
> myself or my wife print it goes through, but if the kids are logged in, it
> goes to the 'moderated' queue.
>
> Is there anything out there or do I have to polish my PHP/Python skills?

This is all doable.  Firstly, configure the Win98/XP box to use an Apple
Laserwriter instead of the actual printer you have.  Then configure Samba so
that instead of calling 'lpr' or the CUPS enquivelent, it calls a script of
your choosing.  You can then do whatever you want.

For instance, you can have it check the username supplied and either stick it
straight in the queue if it is you or your better half, or place it in a
holding pen if it's from one of your offspring.

Then you can simply knock up a PHP route to view the jobs and say Yes/No to
printing them.  You may need to convert the image to a browser friendly
format such as PDF first.

I've included a small script I wrote a while back.  This was designed to take
a print request from a PC using the Apple driver, convert it to PDF and stick
it back on that PC in the \\<PCNAME>\PDF shared folder.  Also included is the
smb.conf entry.

pdf]
   comment = PDF Generator
   path = /var/spool/samba
   browseable = yes
   public = yes
   guest ok = yes
   printable = yes
   print command = /usr/bin/smbtopdf '/var/spool/samba/' '%f' '%J' '%m'

[root@dcomp2 root]# cat /usr/bin/smbtopdf
#!/bin/bash

exec >>/tmp/smbtopdf
exec 2>&1

path="$1"
fname="$2"
Job="$3"
machine="$4"

Job=`echo $Job|sed 's/ /_/g'`
echo "machine='$machine' file='$fname' job='$Job'"
cd $path
/usr/bin/ps2pdf -sPAPERSIZE=a4 $fname $fname.pdf
/usr/bin/smbclient //$machine/PDF -N<<EOF
put $fname.pdf $Job.pdf
EOF

rm $fname $fname.pdf
echo
[root@dcomp2 root]#


--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000