#!/bin/bash # # backup job user title num-copies options [ filename ] # if [ $# -eq 0 ]; then echo file backup \"Unknown\" \"File Backup\" 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 # PDFOPT="-r300 -dAutoRotatePages=/None -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dNOPLATFONTS" PFAD=${DEVICE_URI#backup:} test -z "$PFAD" && PFAD=`date +"/home/daten/%Y/archiv/%m"` TITLE=$3 test -z "$TITLE" && TITLE=unknown FILE=`date +"$PFAD/$TITLE-%Y-%m-%d-%H-%M-%S.pdf"` DIR=`dirname "$FILE"` echo "INFO: File is $FILE" 1>&2 test ! -x "$DIR" && mkdir -p -m 2755 "$DIR" 2>&1 | sed s,^,'ERROR: ',1 >&2 test ! -x "$DIR" && echo "ERROR: creating directory failed: $DIR" 1>&2 && exit -1 if [ $# -eq 6 ]; then ps2pdf13 $PDFOPT $6 $FILE | sed s,^,'ERROR: ',1 >&2 else ps2pdf13 $PDFOPT - $FILE | sed s,^,'ERROR: ',1 >&2 fi chmod a+r,a-w "$FILE" echo "INFO: Ready to print ..." 1>&2 exit 0