1 | # $Id$ |
---|
2 | # |
---|
3 | # Tea4CUPS : Tee for CUPS |
---|
4 | # |
---|
5 | # (c) 2005 Jerome Alet <alet@librelogiciel.com> |
---|
6 | # This program is free software; you can redistribute it and/or modify |
---|
7 | # it under the terms of the GNU General Public License as published by |
---|
8 | # the Free Software Foundation; either version 2 of the License, or |
---|
9 | # (at your option) any later version. |
---|
10 | # |
---|
11 | # This program is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with this program; if not, write to the Free Software |
---|
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | # |
---|
20 | # |
---|
21 | |
---|
22 | # First we set all top-level directives in the [global] section |
---|
23 | [global] |
---|
24 | |
---|
25 | # Should we log debugging information to CUPS' error_log file ? |
---|
26 | # defaults to No if unset. |
---|
27 | debug : yes |
---|
28 | |
---|
29 | # In which directory will we create our files ? It must already exist ! |
---|
30 | # This directive MUST be present since there's no sane default value. |
---|
31 | # Can be set either in the [global] section or any print queue section. |
---|
32 | # The value defined in a print queue section takes precedence over the |
---|
33 | # value defined in the [global] section. |
---|
34 | # directory : /var/spool/tea4cups/ |
---|
35 | directory : /var/spool/cups/ |
---|
36 | |
---|
37 | # Should Tea4CUPS keep the files it creates once all tees have ended ? |
---|
38 | # Defaults to No if unset, meaning that files are automatically deleted |
---|
39 | # once all tees have ended. |
---|
40 | # Can be set either in the [global] section or any print queue section. |
---|
41 | # The value defined in a print queue section takes precedence over the |
---|
42 | # value defined in the [global] section. |
---|
43 | # BEWARE : this may use huge amounts of disk space ! |
---|
44 | # keepfiles : yes |
---|
45 | |
---|
46 | # Should we serialize the launch of all tees : launch one tee after |
---|
47 | # the other to save some system resources. |
---|
48 | # Defaults to No if unset, meaning that all tees (or hooks) are launched in |
---|
49 | # parallel. |
---|
50 | # |
---|
51 | # NB : in any case, hooks or tees names are sorted alphabetically and |
---|
52 | # are launched in this sort order (obviously when launched in parallel |
---|
53 | # this is unnoticeable). |
---|
54 | # |
---|
55 | # Can be set either in the [global] section or any print queue section. |
---|
56 | # The value defined in a print queue section takes precedence over the |
---|
57 | # value defined in the [global] section. |
---|
58 | # This value also applies to prehooks and posthooks (see below) |
---|
59 | # serialize : yes |
---|
60 | |
---|
61 | # When executing the contents of a tee, prehook or posthook directive, |
---|
62 | # tea4cups makes the following environment variables available to your |
---|
63 | # own commands : |
---|
64 | # |
---|
65 | # TEAPRINTERNAME : The print queue name. |
---|
66 | # TEADIRECTORY : Tea4CUPS output directory. |
---|
67 | # TEADATAFILE : Full name of Tea4CUPS work file (in $TEADIRECTORY). |
---|
68 | # TEAJOBSIZE : Job's size in bytes. |
---|
69 | # TEAMD5SUM : MD5 sum of the job's datas. |
---|
70 | # TEACLIENTHOST : Client's hostname or IP address. |
---|
71 | # TEAJOBID : Job's Id. |
---|
72 | # TEAUSERNAME : Name of the user who launched the print job. |
---|
73 | # TEATITLE : Job's title. |
---|
74 | # TEACOPIES : Number of copies requested. |
---|
75 | # TEAOPTIONS : Options of the print job. |
---|
76 | # TEAINPUTFILE : Job's data file or empty when job read from stdin. |
---|
77 | # TEABILLING : Job's billing code (lp -o job-billing=SomeCode file.ps) |
---|
78 | # TEACONTROLFILE : Job's IPP message file (usually /var/spool/cups/c?????) |
---|
79 | # |
---|
80 | # Your own commands will mostly be interested in TEADATAFILE which is |
---|
81 | # the name of the file from which your commands may extract the final |
---|
82 | # job's datas. Don't rely on TEAINPUTFILE, use TEADATAFILE instead |
---|
83 | # since the first one may be empty depending on your printer driver. |
---|
84 | |
---|
85 | # Now defines some default tees which will always be launched |
---|
86 | # at the same time that the job's datas are being sent to the |
---|
87 | # printer. |
---|
88 | # The tee names are completely free BUT THEY MUST BEGIN WITH 'tee_' |
---|
89 | # |
---|
90 | # These are just some stupid examples. |
---|
91 | #tee_0 : cat $TEADATAFILE >/tmp/$TEAJOBID.prn |
---|
92 | #tee_pdf : cat $TEADATAFILE | su -c "lp -dPDFGenerator" $TEAUSERNAME |
---|
93 | |
---|
94 | # Some hooks : prehooks and posthooks |
---|
95 | # |
---|
96 | # Contrary to tees, prehooks are guaranteed to be launched |
---|
97 | # BEFORE the job's datas are sent to the printer, and |
---|
98 | # posthooks are guaranteed to be launched AFTER the job's |
---|
99 | # datas have been sent to the printer. |
---|
100 | # |
---|
101 | # prehook names are completely free BUT THEY MUST BEGIN WITH 'prehook_' |
---|
102 | # posthook names are completely free BUT THEY MUST BEGIN WITH 'posthook_' |
---|
103 | # |
---|
104 | # An additionnal environment variable is made available to posthooks, |
---|
105 | # named TEASTATUS which contains the exitcode of the real CUPS backend. |
---|
106 | # The normal value is 0, meaning that the real CUPS backend exited |
---|
107 | # successfully. Any other value indicates that a problem occured |
---|
108 | # in the CUPS backend which handles the transmission of the job |
---|
109 | # to the printer. |
---|
110 | # |
---|
111 | # prehook_0 : echo "Your print job has been accepted" | smbclient -M $TEAUSERNAME |
---|
112 | # posthook_0 : echo "Your print job has been printed with status $TEASTATUS" | smbclient -M $TEAUSERNAME |
---|
113 | # |
---|
114 | # NB : as a special feature, any prehook which exits with a -1 status (255) |
---|
115 | # causes the job to NOT be sent to the real backend, effectively cancelling it. |
---|
116 | # None of the tees and posthooks gets executed in this case, but all |
---|
117 | # remaining prehooks are still executed. |
---|
118 | # |
---|
119 | |
---|
120 | |
---|
121 | # Sample section for print queue HP2100 |
---|
122 | # Uncomment and adapt to your needs. |
---|
123 | # |
---|
124 | #[HP2100] |
---|
125 | # |
---|
126 | # By using a same tee name as in the [global] section, the new |
---|
127 | # value takes precedence |
---|
128 | #tee_0 : cat $TEADATAFILE >~$TEAUSERNAME/savejobs/$TEAJOBID.prn |
---|
129 | |
---|
130 | # An empty value deletes a value defined in the [global] section |
---|
131 | # so this particular tee doesn't get executed. |
---|
132 | #tee_pdf : |
---|
133 | |
---|
134 | # A reflector which produces 4 copies each time : |
---|
135 | #tee_4copies : lp -dotherprinter -n4 $CUPSDATAFILE |
---|
136 | |
---|
137 | # A simple accounting mechanism |
---|
138 | #tee_accounting : echo $TEAPRINTERNAME $TEAJOBID $TEAUSERNAME $TEABILLING `pkpgcounter $TEADATAFILE` >/var/log/printaccounting.log |
---|
139 | |
---|
140 | # Some additionnal hooks to forbid duplicate jobs : |
---|
141 | # The prehook will use the history file to filter out duplicate jobs |
---|
142 | # checkdupes is an hypothetical command which exits -1 if the current print |
---|
143 | # job is a duplicate (same MD5 sum already found in history) |
---|
144 | #prehook_to_filter_duplicates : /usr/local/bin/checkdupes $TEAMD5SUM /tmp/jobmd5sums |
---|
145 | #posthook_to_filter_duplicates : echo "$TEAJOBID : $TEAMD5SUM" >>/tmp/jobmd5sums |
---|