diff options
author | John Terpstra <jht@samba.org> | 2002-10-30 03:50:23 +0000 |
---|---|---|
committer | John Terpstra <jht@samba.org> | 2002-10-30 03:50:23 +0000 |
commit | a207251c2fb3145201e4bbd770bb0d79c7180eb5 (patch) | |
tree | b12fc36f2111e3f5308c9cb87c0a9e119464e7bf /packaging/Mandrake/samba-print-pdf.sh | |
parent | 0d929993c8805785389f58605a2b0bc717eca27c (diff) | |
download | samba-a207251c2fb3145201e4bbd770bb0d79c7180eb5.tar.gz samba-a207251c2fb3145201e4bbd770bb0d79c7180eb5.tar.bz2 samba-a207251c2fb3145201e4bbd770bb0d79c7180eb5.zip |
Adding Buchan Milne's updates.
(This used to be commit d816c35c1d8db343c76a32a6d01952d2c192b092)
Diffstat (limited to 'packaging/Mandrake/samba-print-pdf.sh')
-rw-r--r-- | packaging/Mandrake/samba-print-pdf.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/packaging/Mandrake/samba-print-pdf.sh b/packaging/Mandrake/samba-print-pdf.sh new file mode 100644 index 0000000000..5c744f0a83 --- /dev/null +++ b/packaging/Mandrake/samba-print-pdf.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# samba-print-pdf +# This is a script which allows you to set up a virtual printer on samba +# which will take the file (generated by a postscript filter on windows) +# and turn it into a PDF, informing the user of where it is when it +# is done +# +# Buchan Milne <bgmilne@cae.co.za> 20020723 +# +# Arguments: +# $1 = file (usually passed with %s from samba) +# $2 = unix prefix to where to place the file (~%u should work) +# $3 = windows prefix to the same location (\\%L\%u should work) +# $4 = user/computer to send a notification to (%u or %m) +# $5 = IP address of client (%I) + + +PS2PDF=ps2pdf13 +OPTIONS="-dAutoFilterColorImages=false -sColorImageFilter=FlateEncode" +INPUT=$1 +KEEP_PS=1 +PERMS=640 +INFILE=$(basename $INPUT) +BASEFILE=pdf-service + +#make a temp file to use for the output of the PDF +OUTPUT=`mktemp -q $2/$BASEFILE-XXXXXX` +if [ $? -ne 0 ]; then + echo "$0: Can't create temp file $2/$BASEFILE-XXXXXX, exiting..." + exit 1 +fi + +WIN_OUTPUT="$3\\`basename $OUTPUT`" + +# create the PDF: +$PS2PDF $OPTOINS $INPUT $OUTPUT.pdf >/dev/null 2>&1 + +# Generate a message to send to the user, and deal with the original file: +MESSAGE=$(echo "Your PDF file has been created as $WIN_OUTPUT.pdf\n") + +if [ $KEEP_PS ];then + mv $INPUT $OUTPUT.ps + MESSAGE=$(echo "$MESSAGE and your postscript file as $WIN_OUTPUT.ps") + # Fix permissions on the generated files + chmod $PERMS $OUTPUT.ps +else + rm -f $INPUT + chmod $PERMS $OUTPUT.ps $OUTPUT.pdf + # Fix permissions on the generated files +fi + +chmod $PERMS $OUTPUT.ps $OUTPUT.pdf + +#Remove empty file from mktemp: +rm -f $OUTPUT + +# Send notification to user +echo -e $MESSAGE|smbclient -M $4 -I $5 -U "PDF Generator" >/dev/null 2>&1 + |