#!/bin/bash
# CUPS filter to process DVI files using dvips
# Create a sandbox for working if input on stdin
if [ $# -lt 6 ]; then
sandbox=${TMPDIR-/tmp}/cups-dvitops.$$
(umask 077 && mkdir $sandbox) || {
echo "Cannot create temporary directory! Exiting." 1>&2
exit 1
}
fn="$sandbox/cups-dvitops.$$"
cat > "$fn"
else
fn="$6"
fi
# Call dvips quietly, securely and with output to stdout
dvips -R -q -o - "$fn"
# Erase sandbox if we created one
if [ $# -lt 6 ]; then
rm -rf "$sandbox"
fi
[ian@attic4 ~]$ cat /etc/cups/dvitops.types
# Local MIME definition for DVI files
application/x-dvi dvi string(0,<F702>)
[ian@attic4 ~]$ cat /etc/cups/dvitops.convs
# Local DVI to PostScript filter for CUPS
application/x-dvi application/postscript 50 dvitops