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