#!/bin/bash # # vorlage job user title num-copies options [ filename ] # # diese Datei steuert die virtuellen Drucker # SaveToTemp SaveToDisk und SaveToVorlage # if [ $# -eq 0 ]; then echo file vorlage \"Unknown\" \"Template File\" exit 0 fi if [ "$#" -lt "5" ]; then echo "ERROR: Number of arguments ($#) is wrong" 1>&2 exit 1 fi if [ "$#" -gt "6" ]; then echo "ERROR: Number of arguments ($#) is wrong" 1>&2 exit 1 fi # # globals # echo "INFO: cmd is $DEVICE_URI" 1>&2 PFAD=${DEVICE_URI#vorlage:} test -z "$PFAD" && PFAD=/home/daten/vorlagen/drucker TITLE=$3 test -z "$TITLE" && TITLE=unknown FILE="$PFAD/$TITLE.eps" DIR=`dirname "$FILE"` echo "INFO: File is $FILE" 1>&2 test ! -x "$DIR" && mkdir -p -m 2775 "$DIR" 2>&1 | sed s,^,'ERROR: ',1 >&2 test ! -x "$DIR" && echo "ERROR: creating directory failed: $DIR" 1>&2 && exit -1 test -r "$FILE" && chmod a+w "$FILE" if [ $# -eq 6 ]; then ps2epsi $6 $FILE | sed s,^,'ERROR: ',1 >&2 else tmpfile=/tmp/ps2eps.$$.ps /usr/bin/pstops 1:0 /dev/stdin $tmpfile test ! -r $tmpfile && echo >&2 "ERROR: no tmpfile found: $tmpfile" || /usr/bin/ps2epsi $tmpfile $FILE | sed s,^,'ERROR: ',1 >&2 rm -f $tmpfile fi chmod a+r,a-w "$FILE" echo "INFO: Ready to print ..." 1>&2 exit 0