#!/bin/sh

echo "$1" | grep -qi pdf$ || exit 1

	pdf2ps /dev/stdin /dev/stdout < "$1" |
	psbook |
	psnup -2 -s1 |
	lpr-cups -P CUPS-PDF -T "tmp_brochure"
#cat > /tmp/z.ps ; exit

sleep 5
NEWNAME=`echo "$1" | sed 's|.pdf$|_brochure.pdf|'`
mv /var/spool/cups-pdf/$USER/tmp_brochure.pdf "$NEWNAME"

