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