Re: [SLE] [cross post mdk SuSE] Samba Print to PDF

From: Sid Boyce (sboyce_at_blueyonder.co.uk)
Date: 08/24/05

  • Next message: eddieleprince: "[SLE] more on umask"
    Date: Wed, 24 Aug 2005 08:20:25 +0100
    To: Suse Linux <suse-linux-e@suse.com>, mandrake <expert@mandrivalinux.org>
    
    

    david rankin wrote:
    > Mates,
    >
    > I apologize to the cannibalizing distributions, but in having
    > problems with pdf-gen or, as otherwise known, print-pdf, I thought I
    > would share a little on just how easy it actually is to get working on
    > any system. The cannibalizing involved taking the mdk print-pdf script
    > and dumping it into SuSE -- nothing less than blasphemy. Anyway it works.
    >
    No apologies necessary to me, I do that all the time. I wish there were
    some things in both distros, e.g in Mandriva bash completion can't
    distinguish between a directory and a file, cd [TAB] presents you with
    both. On Mandriva when installing a new kernel and you haven't got
    NVIDIA compiled in, it does the smart thing, changes xorg.conf and loads
    "nv". On Mandriva, the bash prompt is an abortion, so I've grafted the
    SuSE prompt on to it.
    One thing that has me still baffled, I have a Mandriva x86 box where I
    can only do a ssh login from the SuSE 9.3 x86_64 laptop, both the other
    Mandriva x86 box and this SuSE 9.3 x86 box can't. You can do the full
    range of commands scp and ssh, just logins fail - you can ignore this as
    it's to be subject of a later post.
    Regards
    Sid.

    > BACKGROUND
    >
    > I had pdf-gen working on mdk 2005LE as a new box to replace the 7.2
    > box at work. After transition, (and all the pain that goes with moving
    > dhcp, dyn-dns (bind8-bind9, TSIG updates, named.keys), samba (different
    > share scheme), pptp, postfix (shoot me again), imap, httpd (1.3-2.x ..
    > damn new deny unless explicitly allowed rules), ssh (keygen issues),
    > ftp, cups, etc.....) pdf-gen was reporting "out of memory" errors on XP
    > clients. Made no sense, since (no pun intended) it was working fine on
    > the new box before adding additional shares. So I dug into print-pdf to
    > try and get it working.
    >
    > TEST -SETTING IT UP ON SUSE
    >
    > To troubleshoot, I thought I would start from scratch and try and get
    > it working on my SuSE 9.0 server at home which had no such capability. I
    > figured I could learn how it worked in the process and then fix the
    > 2005LE box at work.
    >
    > The basic process was:
    >
    > (1) to copy the mdk print-pdf script to the SuSE box. That is the:
    >
    > [david@bonza scripts]$ ll /usr/share/samba/scripts/
    > total 12
    > -rwxr-xr-x 1 root root 3555 Apr 4 09:03 print-pdf*
    >
    > (note file permissions)
    >
    > The actual script is:
    > ******************************
    > #!/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
    > #
    > # (c) Buchan Milne <bgmilne@cae.co.za> 2002
    > # License: GPLv2
    > # Changelog
    > # v0.0.6 20030428
    > # - Allow options passed as env. variables from print command
    > # - Inline and simplify sed (use tr) clean script
    > # - Ensure file arrives in PREFIX even if TEMP is used without provided
    > name
    > # - Changes from Joshua M. Schmidlkofer <joshua@imr-net.com> 20030425
    > # - Debugging, adjustments, and corrections.
    > # - Stupid sed sanitizing script. [probably horribly inefficient also].
    > # - Temp file usage cleanup.
    > # v0.0.5 20020723
    > # - Add support for preset settings
    > # - Allow passing of filename provided by client as final filename
    > #
    > # 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)
    > # $6 = Name of destination file without extension (%J)
    > # $7 = PDF setting (prepress,print,screen etc)
    > #
    > # If you want to customise any of the following configuration defaults,
    > # you can place them in the file /etc/samba/print-pdf.conf.
    > # If you need to modify anything in this script, please provide me with
    > your
    > # changes, preferably in such a way that the changes are configurable.
    >
    > PS2PDF=ps2pdf13
    > OPTIONS="-dAutoFilterColorImages=false -sColorImageFilter=FlateEncode"
    > #Values taken from arguments:
    > INPUT=$1
    > PREFIX="$2"
    > WINBASE=$(echo "$3"|sed -e 's,/,\\\\,g')
    > #NAME=`echo "$6"|sed -e 's/[&/:{}\\\[<>$#@*^!?=|]/-/g;s/\]/-/g'`
    > NAME=`echo "$6"|tr '[:punct:]' '[-*]'`
    >
    > # Source config file if it exists:
    > CONFFILE=/etc/samba/print-pdf.conf
    > [ -e $CONFFILE ] && . $CONFFILE
    >
    > #Values not taken as arguments, could be set via env. vars (?) or config
    > file
    > KEEP_PS=${KEEP_PS=0}
    > PERMS=${PERMS=640}
    > BASEFILE=${BASEFILE=pdf-service}
    > TEMP="${TEMP=$2}"
    > UMASK=${UMASK=006}
    >
    > #Make sure that destination directory exists
    > mkdir -p "$PREFIX"
    >
    > INFILE=$(basename $INPUT)
    >
    > umask $UMASK
    >
    > [ -n "$NAME" ] && TEMP="$PREFIX"
    >
    > #make a temp file to use for the output of the PDF
    > OUTPUT=`mktemp -q $TEMP/$BASEFILE-XXXXXX`
    > if [ $? -ne 0 ]; then
    > echo "$0: Can't create temp file $TEMP/$OUTPUT, exiting..."
    > exit 1
    > fi
    > if [ -n "$NAME" ]; then
    > FINALOUTPUT="$PREFIX/$NAME"
    > else
    > FINALOUTPUT="$OUTPUT"
    > fi
    > if [ -n "$7" ]; then
    > OPTIONS="$OPTIONS -dPDFSETTINGS=/${7#pdf-}"
    > else
    > OPTIONS="$OPTIONS -dPDFSETTINGS=/default"
    > fi
    >
    > WIN_OUTPUT="$WINBASE\\"`basename "$FINALOUTPUT"`
    > #mv "$INPUT" "$INPUT.ps";INPUT="$INPUT.ps"
    >
    > # create the pdf
    > $PS2PDF $OPTIONS "$INPUT" "$OUTPUT.pdf" >/dev/null 2>&1
    > mv -f "${OUTPUT}.pdf" "${FINALOUTPUT}".pdf
    >
    > # 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")
    >
    > # Cleanup
    > if [ $KEEP_PS != 0 ];then
    > mv -f $INPUT "${FINALOUTPUT}".ps
    > MESSAGE=$(echo "$MESSAGE and your postscript file as $WIN_OUTPUT.ps")
    > # Fix permissions on the generated files
    > chmod $PERMS "${FINALOUTPUT}".ps "${FINALOUTPUT}".pdf
    > else
    > rm -f $INPUT
    > # Fix permissions on the generated files
    > chmod $PERMS "${FINALOUTPUT}".pdf
    > fi
    >
    > #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
    >
    > ******************************
    >
    > literally .... copy and paste it into ...
    > /usr/share/samba/scripts/print-pdf on whatever box you are using
    >
    > The permissions are:
    >
    > [david@bonza scripts]$ ls -al /usr/share/samba/scripts/
    > total 20
    > drwxr-xr-x 2 root root 4096 Jul 16 10:24 ./
    > drwxr-xr-x 3 root root 4096 Apr 4 09:03 ../
    > -rwxr-xr-x 1 root root 3555 Apr 4 09:03 print-pdf*
    > -rwxr-x--- 1 root adm 5757 Apr 4 09:03 smb-migrate*
    >
    > (2) Confirm you have ps2pdf13 installed or edit the script to work with
    > what you do have. You will at least have one of the following if you
    > have ghostscript installed:
    >
    > skyline:/home/david # ls /usr/bin/ps2*
    > /usr/bin/ps2ascii /usr/bin/ps2frag /usr/bin/ps2pdf12
    > /usr/bin/ps2pdf14 /usr/bin/ps2pk
    > /usr/bin/ps2epsi /usr/bin/ps2pdf /usr/bin/ps2pdf13
    > /usr/bin/ps2pdfwr /usr/bin/ps2ps
    >
    > (3) Then, just edit /etc/samba/smb.conf and add the following share:
    >
    > [pdf-gen]
    > path = /var/tmp
    > guest ok = No
    > printable = Yes
    > comment = PDF Generator (only valid users)
    > printing = bsd
    > printcap name = cups
    > #print command = /usr/share/samba/scripts/print-pdf file path win_path
    > recipient IP &
    > print command = /usr/share/samba/scripts/print-pdf "%s" "%H" "//%L/%u"
    > "%m" "%I" "%J" &
    > lpq command = /bin/true
    >
    > (4) Then (run testparm -- always; and (5) restart Samba):
    >
    > On SuSE (as root): rcsmb restart
    > On mdk (as root): /etc/rc.d/init.d/smb restart
    >
    > (6) Then from M$ clients, browse to the pdf-gen share and double-click
    > it or control panel - printers - add printer - network and select it.
    > Choose OK to 'manually select' the driver. Choose one of the latest HP
    > Laserjet postscript (PS) drivers; (eg. Laserjet 8150 color PS, or
    > Laserjet 6P/6.. PS, or Laserjet 5, etc..
    >
    > That's it, that's all it takes! Open Word, (choose your most used app),
    > select pdf-gen as your printer and BINGO your pdf is created in the
    > users home directory -- no questions asked. Damn slick! (but it still
    > hasn't solved my original problem, but -- learning has occurred)
    >
    > But FWIIW, I thought I would post it. YMMV. But from simply having to
    > dump a mdk script onto suse, confirm that ps2pdf13 was there, set the
    > permissions, add a share to smb.conf, add a printer to the weak clients
    > and presto -- your done, your printing to pdf from anywhere. Anyway, I
    > thought it was cool.
    >
    > For you industrious souls (Anne -- 1st name that comes to mind), feel
    > free to dump this into a wiki. (typos and all)
    >
    > --
    > David C. Rankin, J.D., P.E.
    > RANKIN LAW FIRM, PLLC
    > 510 Ochiltree Street
    > Nacogdoches, Texas 75961
    > (936) 715-9333
    > (936) 715-9339 fax
    > www.rankinlawfirm.com

    -- 
    Sid Boyce ... Hamradio License G3VBV, Keen licensed Private Pilot
    Retired IBM/Amdahl Mainframes and Sun/Fujitsu Servers Tech Support 
    Specialist
    Microsoft Windows Free Zone - Linux used for all Computing Tasks
    -- 
    Check the headers for your unsubscription address
    For additional commands send e-mail to suse-linux-e-help@suse.com
    Also check the archives at http://lists.suse.com
    Please read the FAQs: suse-linux-e-faq@suse.com
    

  • Next message: eddieleprince: "[SLE] more on umask"

    Relevant Pages

    • Re: Newby questions...please be kind
      ... I use NFS between SuSE boxes. ... remote home for myself and wife, ... To execute a script file you should first change its execute bit either ...
      (alt.os.linux.suse)
    • Re: [SLE] Printer Problems
      ... On machine-2 I am trying out Suse 10.0. ... in particular the "Configuring CUPS in the Network" section ... You must allow print queue access on the Mandriva machine. ...
      (SuSE)
    • Re: [SLE] The future of Mandrake as we knew it. Switch to SuSE.
      ... Linux-Magazine Pro and it includes the DVD for Mandriva One. ... For example I purchased a SuSE book that had SuSE10.0 in it. ... at any one time as on updates breakage was just about equal to fixes. ... Linux users in the UK are very happy with the distro's that come with ...
      (SuSE)
    • Re: Suse Equivalent of rc.local
      ... In suse 10.2, the nearest thing I can find to rc.local is ... You put your script into /etc/init.d ... but remember that statics can be assigned by your dhcp ... I was just about to point you to the skeleton/template script file ...
      (alt.os.linux.suse)
    • Re: Size of wtmp files
      ... > wtmp file. ... > truncated, then I have to use a somewhat clumsy script to zcat the files, ... Yeah, I've got to repair my ignorance of suse real soon, or I would ... Didn't really occur to me that logrotate ...
      (comp.os.linux.misc)