summaryrefslogtreecommitdiff
path: root/printpdf
blob: 98e722dce51448c8e3d37756c96138500e2ea2bb (plain)
  1. #!/bin/sh
  2. # Simple script to convert a specified postscript file into a PDF document
  3. # and place it in a location that is shared by the Samba server.
  4. #
  5. # Arguments:
  6. # 1st - The name of the spool file
  7. #
  8. # John Bright, 2001, jbright@winfordeng.com
  9. # We will create the pdf into a temporary file based upon the current date and time.
  10. # After we are finished, we'll rename it to a file with the same date, but ending
  11. # in .pdf. We do this because if a user tries to open a PDF that is still being written,
  12. # they will get a message that it is corrupt, when it is actually just not done yet.
  13. DATE=`date +%b%d-%H%M%S`
  14. # Directory in which to place the output
  15. # Be sure this directory exists and is writable by the user that Samba
  16. # is running as (for example, the nobody user)
  17. OUTDIR=/home/fsadmin/COMMON/pdfshare
  18. FILENAME=$1
  19. USERNAME=$2
  20. #FILENAME="/tmp/test.ps"
  21. LOGFILE="/tmp/printpdf.log"
  22. LOOP='yes'
  23. while [ "$LOOP" = 'yes' ]; do
  24. FILESTATE=`/usr/sbin/lsof | grep $FILENAME`
  25. echo "$FILESTATE" >> $LOGFILE
  26. if [ "$FILESTATE" != '' ]; then
  27. sleep 5
  28. echo "Printfile is still open. Sleeping 5...">> $LOGFILE
  29. else
  30. ps2pdf $FILENAME /tmp/$DATE.temp
  31. mv /tmp/$DATE.temp $OUTDIR/$USERNAME-$DATE.pdf
  32. rm $FILENAME
  33. echo "PDF print to file $OUTDIR/$USERNAME-$DATE.pdf is finished" >> $LOGFILE
  34. LOOP='no'
  35. fi
  36. done