Cups + Samba + PDF
Inviato: lun 3 mag 2004, 17:55
Ciao a tutti
<BR>
<BR>sto diventando scemo
per tentare di configurare un generatore di PDF tramite samba+cups, usando le versioni fornite con la slack 9.1.
<BR>Per farlo ho messo uno script di backend in cups, copiandolo da kdeprinting.org e modificandolo leggermente.
<BR>Durante i primi test mi creava dei PDF vuoti, ma avendo abilitato lo storico dei jobs di cups mi trovavo tutto a posta, allora smanettando (non è che capisca un granchè ma non penso di aver fatto grosse vaccate) sono arrivato ad avere un qualcosa di funzionante, cioè :
<BR>
<BR>LOGFILE=/tmp/pdf.log
<BR>PDFBIN=`which ps2pdf`
<BR>FILENAME=
<BR># this is borrowed from printpdf script for the filename
<BR>PRINTTIME=`date +%b%d-%H%M%S`
<BR>
<BR>echo "Executable: $PDFBIN" > $LOGFILE
<BR>echo "Arguments: |$1|$2|$3|$4|$5|$6|" >> $LOGFILE
<BR>echo $# $PRINTTIME >> $LOGFILE
<BR>
<BR># case of no argument, prints available URIs
<BR>if [ $# -eq 0 ]; then
<BR> if [ ! -x "$PDFBIN" ]; then
<BR> exit 0
<BR> fi
<BR> echo "direct pdf \"Unknown\" \"PDF Writing\""
<BR> exit 0
<BR>fi
<BR>
<BR># case of wrong number of arguments
<BR>if [ $# -ne 5 -a $# -ne 6 ]; then
<BR> echo "Usage: pdf job-id user title copies options [file]"
<BR> exit 1
<BR>fi
<BR>
<BR># MIE MODIFICHE QUI :
<BR># non mi creava alcun output, ho pensato di dover leggere da stdin
<BR>if [ "$5" = "" ]; then
<BR> tempfile=/var/tmp/$$.prn
<BR> cat > $tempfile
<BR>else
<BR> tempfile = $6
<BR>fi
<BR>
<BR># get PDF directory from device URI, and check write status
<BR>PDFDIR=${DEVICE_URI#pdf:}
<BR>if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
<BR> echo "ERROR: directory $PDFDIR not writable"
<BR> exit 1
<BR>fi
<BR>
<BR>echo "PDF directory: $PDFDIR" >> $LOGFILE
<BR>
<BR># generate output filename
<BR>OUTPUTFILENAME=
<BR>if [ "$3" = "" ]; then
<BR> OUTPUTFILENAME="$PDFDIR/unknown.pdf"
<BR>else
<BR> # OUTPUTFILENAME="$PDFDIR/${3//[^[:alnum:]]/_}.pdf"
<BR> # I changed this to user name, and the printtime to track down who
<BR> # printed the PDF and when, samba printing just uses nobody
<BR>
<BR> OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
<BR> echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
<BR>fi
<BR>
<BR>echo "Output file name: $OUTPUTFILENAME" >> $LOGFILE
<BR>
<BR># run ghostscript
<BR>if [ $# -eq 6 ]; then
<BR> $PDFBIN $6 "$OUTPUTFILENAME"
<BR>#>& /dev/null
<BR>else
<BR># MIE MODIFICHE QUI
<BR># usa tempfile
<BR># $PDFBIN - "$OUTPUTFILENAME" >& /dev/null
<BR> $PDFBIN $tempfile "$OUTPUTFILENAME" >& /dev/null
<BR>fi
<BR>
<BR># modify ownership and permissions on the file
<BR># - world readable
<BR># - owns to user specified in argument
<BR>chmod a+r "$OUTPUTFILENAME"
<BR>if [ "$2" != "" ]; then
<BR> chown $2 "$OUTPUTFILENAME"
<BR>fi
<BR>
<BR>exit 0
<BR>
<BR>
<BR>Ora non capisco una cosa... ogni pdf creato si chiama "root-" + qualcosa, non "nomeutente-", e nei log vedo che questo cacchio di backend biene chiamato sempre come root.
<BR>
<BR>Come faccio a passare l´utente da samba a cups invece di avere tutto come root?
<BR>C´è qualcosa in particolare da verificare in smb.conf o cupsd.conf?
<BR>
<BR>O forse sono senza speranza ed è meglio passare alla coltivazione delle rape?
<BR>
<BR>Grazie
<br>
<BR>
<BR>sto diventando scemo
<BR>Per farlo ho messo uno script di backend in cups, copiandolo da kdeprinting.org e modificandolo leggermente.
<BR>Durante i primi test mi creava dei PDF vuoti, ma avendo abilitato lo storico dei jobs di cups mi trovavo tutto a posta, allora smanettando (non è che capisca un granchè ma non penso di aver fatto grosse vaccate) sono arrivato ad avere un qualcosa di funzionante, cioè :
<BR>
<BR>LOGFILE=/tmp/pdf.log
<BR>PDFBIN=`which ps2pdf`
<BR>FILENAME=
<BR># this is borrowed from printpdf script for the filename
<BR>PRINTTIME=`date +%b%d-%H%M%S`
<BR>
<BR>echo "Executable: $PDFBIN" > $LOGFILE
<BR>echo "Arguments: |$1|$2|$3|$4|$5|$6|" >> $LOGFILE
<BR>echo $# $PRINTTIME >> $LOGFILE
<BR>
<BR># case of no argument, prints available URIs
<BR>if [ $# -eq 0 ]; then
<BR> if [ ! -x "$PDFBIN" ]; then
<BR> exit 0
<BR> fi
<BR> echo "direct pdf \"Unknown\" \"PDF Writing\""
<BR> exit 0
<BR>fi
<BR>
<BR># case of wrong number of arguments
<BR>if [ $# -ne 5 -a $# -ne 6 ]; then
<BR> echo "Usage: pdf job-id user title copies options [file]"
<BR> exit 1
<BR>fi
<BR>
<BR># MIE MODIFICHE QUI :
<BR># non mi creava alcun output, ho pensato di dover leggere da stdin
<BR>if [ "$5" = "" ]; then
<BR> tempfile=/var/tmp/$$.prn
<BR> cat > $tempfile
<BR>else
<BR> tempfile = $6
<BR>fi
<BR>
<BR># get PDF directory from device URI, and check write status
<BR>PDFDIR=${DEVICE_URI#pdf:}
<BR>if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
<BR> echo "ERROR: directory $PDFDIR not writable"
<BR> exit 1
<BR>fi
<BR>
<BR>echo "PDF directory: $PDFDIR" >> $LOGFILE
<BR>
<BR># generate output filename
<BR>OUTPUTFILENAME=
<BR>if [ "$3" = "" ]; then
<BR> OUTPUTFILENAME="$PDFDIR/unknown.pdf"
<BR>else
<BR> # OUTPUTFILENAME="$PDFDIR/${3//[^[:alnum:]]/_}.pdf"
<BR> # I changed this to user name, and the printtime to track down who
<BR> # printed the PDF and when, samba printing just uses nobody
<BR>
<BR> OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
<BR> echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
<BR>fi
<BR>
<BR>echo "Output file name: $OUTPUTFILENAME" >> $LOGFILE
<BR>
<BR># run ghostscript
<BR>if [ $# -eq 6 ]; then
<BR> $PDFBIN $6 "$OUTPUTFILENAME"
<BR>#>& /dev/null
<BR>else
<BR># MIE MODIFICHE QUI
<BR># usa tempfile
<BR># $PDFBIN - "$OUTPUTFILENAME" >& /dev/null
<BR> $PDFBIN $tempfile "$OUTPUTFILENAME" >& /dev/null
<BR>fi
<BR>
<BR># modify ownership and permissions on the file
<BR># - world readable
<BR># - owns to user specified in argument
<BR>chmod a+r "$OUTPUTFILENAME"
<BR>if [ "$2" != "" ]; then
<BR> chown $2 "$OUTPUTFILENAME"
<BR>fi
<BR>
<BR>exit 0
<BR>
<BR>
<BR>Ora non capisco una cosa... ogni pdf creato si chiama "root-" + qualcosa, non "nomeutente-", e nei log vedo che questo cacchio di backend biene chiamato sempre come root.
<BR>
<BR>Come faccio a passare l´utente da samba a cups invece di avere tutto come root?
<BR>C´è qualcosa in particolare da verificare in smb.conf o cupsd.conf?
<BR>
<BR>O forse sono senza speranza ed è meglio passare alla coltivazione delle rape?
<BR>
<BR>Grazie