-
Notifications
You must be signed in to change notification settings - Fork 0
/
cupsfilterproxy.sh
64 lines (58 loc) · 1.65 KB
/
cupsfilterproxy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# (c) Kurt Pfeifle <kpfeifle-eG1X/KtG1iM@xxxxxxxxxxxxxxxx>
# <pfeifle-RoXCvvDuEio@xxxxxxxxxxxxxxxx>
# Script is GPL and free to use and modify
#
# Proxy filter for CUPS to harvest intermediate
# files from each step in the filtering chain
#
#
# log a lot of stuff which may be interesting for us
# so we learn how CUPS works.... ;-)
LOG=/tmp/cupsproxyfilter.log
echo "=======================================================" >> $LOG
date >> $LOG
echo "=======================================================" >> $LOG
echo "I am running under this user ID:" >> $LOG
id >> $LOG
echo "=======================================================" >> $LOG
env >> $LOG
echo C $# >> $LOG
echo 0 $0 >> $LOG
echo 1 $1 >> $LOG
echo 2 $2 >> $LOG
echo 3 $3 >> $LOG
echo 4 $4 >> $LOG
echo 5 $5 >> $LOG
echo 6 $6 >> $LOG
# create a directory to store the output of each single filter
# under a uniq name for later debugging purpose
[ -d /tmp/cups-filter-outputs ] || mkdir /tmp/cups-filter-outputs
# in case of wrong number of arguments: print usage hint
if test "$#" -eq "0"; then
echo "ERROR: `basename $0` job-id user title copies options [file]"
1>&2
exit 0
fi
if test "$#" -lt "5"; then
echo "ERROR: Number of arguments ($#) is wrong" 1>&2
echo "USAGE: `basename $0` job-id user title copies options [file]"
1>&2
exit 1
fi
if test "$#" -gt "6"; then
echo "ERROR: Number of arguments ($#) is wrong" 1>&2
echo "USAGE: `basename $0` job-id user title copies options [file]"
1>&2
exit 1
fi
if test "$#" -eq "5"; then
INPUT="-"
else
INPUT="$6"
fi
echo $0.bin "$@" >> $LOG
echo "$#" >> $LOG
echo `id` >> $LOG
exec $0.bin "$@" | tee /tmp/cups-filter-outputs/JobID-$1-$3-`basename
$0`-output