run commands before◀ or after▶ printing or modify📝 the data before it reaches the printer🖨!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
tea4cups/tea4cups.conf

249 lines
9.0 KiB

# $Id$
#
# Tea4CUPS : Tee for CUPS
#
# (c) 2020 dadosch
# (c) 2005-2018 Jerome Alet <alet@librelogiciel.com>
# (c) 2005 Peter Stuge <stuge-tea4cups@cdy.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# First we set all top-level directives in the [global] section
[global]
# Should we log debugging information to CUPS' error_log file ?
# defaults to No if unset.
debug : yes
# In which directory will we create our files ? It must already exist !
# This directive MUST be present since there's no sane default value.
# Can be set either in the [global] section or any print queue section.
# The value defined in a print queue section takes precedence over the
# value defined in the [global] section.
#
# directory : /var/spool/tea4cups/
directory : /var/spool/cups/
# Should Tea4CUPS keep the files it creates once all hooks have ended ?
# Defaults to No if unset, meaning that files are automatically deleted
# once all hooks have ended.
# Can be set either in the [global] section or any print queue section.
# The value defined in a print queue section takes precedence over the
# value defined in the [global] section.
# BEWARE : this may use huge amounts of disk space !
#
# keepfiles : yes
# Should we retry to send the job's datas to the real backend in the case
# it fails ? The default when not set is to try to send the datas only once
# to the real backend.
# Can be set either in the [global] section or any print queue section.
# The value defined in a print queue section takes precedence over the
# value defined in the [global] section.
#
# Syntax : "retry: N,S"
#
# N : number of times to try. If 0, will retry indefinitely, until
# the backend accepts all the datas without error.
#
# S : delay in Seconds between two attempts.
#
# The example below would retry up to three times, at 60 seconds interval.
#
# retry : 3,60
# Should we launch some command when the real CUPS backend fails ?
# Can be set either in the [global] section or any print queue section.
# The value defined in a print queue section takes precedence over the
# value defined in the [global] section.
# IMPORTANT : this directive is only taken into account when the number
# of tries as defined in the 'retry' directive above have expired and
# the real backend still fails.
#
# onfail : echo "Original Backend failed" | /usr/bin/mail -s Tea4CUPS root
# Should we pass incoming datas through a filter command
# BEFORE doing anything else ?
# NB : obvisouly the filter command doesn't have any access to
# the environment variables defined below.
# Can be set either in the [global] section or any print queue section.
# The value defined in a print queue section takes precedence over the
# value defined in the [global] section.
#
# The sample filter below can remove the print job creation date
# from PostScript jobs, in order to more accurately detect duplicate
# jobs (so the MD5SUM would be identical from launch to launch)
#
# filter : /bin/grep -v "%%CreationDate:"
# Should we serialize the launch of all hooks : launch one after
# the other to save some system resources.
# Defaults to No if unset, meaning that all hooks are launched in
# parallel.
#
# NB : in any case, hooks' names are sorted alphabetically and
# are launched in this sort order (obviously when launched in parallel
# this is unnoticeable).
#
# Can be set either in the [global] section or any print queue section.
# The value defined in a print queue section takes precedence over the
# value defined in the [global] section.
#
# serialize : yes
# When executing the contents of a prehook or posthook directive, as
# defined below, tea4cups makes the following environment variables
# available to your own commands :
#
# TEAPRINTERNAME : The print queue name.
# TEADIRECTORY : Tea4CUPS output directory.
# TEADATAFILE : Full name of Tea4CUPS work file (in $TEADIRECTORY).
# TEAJOBSIZE : Job's size in bytes.
# TEAMD5SUM : MD5 sum of the job's datas.
# TEACLIENTHOST : Client's hostname or IP address.
# TEAJOBID : Job's Id.
# TEAUSERNAME : Name of the user who launched the print job.
# TEATITLE : Job's title.
# TEACOPIES : Number of copies requested.
# TEAOPTIONS : Options of the print job.
# TEAINPUTFILE : Job's data file or empty when job read from stdin.
# TEABILLING : Job's billing code (lp -o job-billing=SomeCode file.ps)
# TEACONTROLFILE : Job's IPP message file (usually /var/spool/cups/c?????)
#
# Your own commands will mostly be interested in TEADATAFILE which is
# the name of the file from which your commands may extract the final
# job's datas. Don't rely on TEAINPUTFILE, use TEADATAFILE instead
# since the first one may be empty depending on your printer driver.
# Some prehooks and posthooks
#
# Prehooks are guaranteed to be launched
# BEFORE the job's datas are sent to the printer, and
# posthooks are guaranteed to be launched AFTER the job's
# datas have been sent to the printer.
#
# prehook names are completely free BUT THEY MUST BEGIN WITH 'prehook_'
# posthook names are completely free BUT THEY MUST BEGIN WITH 'posthook_'
#
# An additionnal environment variable is made available to posthooks,
# named TEASTATUS which contains the exitcode of the real CUPS backend.
# If defined, the normal value is 0, meaning that the real CUPS backend exited
# successfully. Any other value indicates that a problem occured
# in the CUPS backend which handles the transmission of the job
# to the printer. See the output of 'man backend' for details.
#
# prehook_0 : echo "Your print job has been accepted" | smbclient -M $TEAUSERNAME
# posthook_0 : echo "Your print job has been printed with status $TEASTATUS" | smbclient -M $TEAUSERNAME
#
# NB : as a special feature, any prehook which exits with a -1 status (255)
# causes the job to NOT be sent to the real backend, effectively cancelling it.
# None of the posthooks gets executed in this case, but all
# remaining prehooks are still executed.
#
#posthook_0 : cat $TEADATAFILE >/tmp/$TEAJOBID.prn
# Another example : a PDF generator which creates PDF documents
# in the user's home directory under the names JOB-iiii.pdf
# where iiii is the job id :
#
# Beware : using ~$TEAUSERNAME here doesn't work because the ~ is not expanded.
# NB : for this to work you might have to print with 'lp -o raw'
#
# prehook_rawpdf : /bin/cat $TEADATAFILE | su $TEAUSERNAME -c "ps2pdf - `/usr/bin/getent passwd $TEAUSERNAME | /usr/bin/cut -f 6,6 -d :`/JOB-$TEAJOBID.pdf"
#
# The posthook below will log all error or warning messages sent by ps2pdf
# to a job specific file in /tmp/. See the explanation on how pre and post
# hooks can communicate at the end of this sample configuration file.
#
# posthook_rawpdf : /bin/cat >/tmp/log_of_pdf_creation_for_job_$TEAJOBID
# Sample section for print queue HP2100
# Uncomment and adapt to your needs.
#
#[HP2100]
#
# By using a same hook name as in the [global] section, the new
# value takes precedence
#
#posthook_0 : cat $TEADATAFILE >/tmp/$TEAUSERNAME-$TEAJOBID.prn
# An empty value deletes a value defined in the [global] section
# so this particular hook doesn't get executed on this printer.
#
#prehook_rawpdf :
# A reflector which produces 4 copies each time :
#
#posthook_4copies : lp -dotherprinter -n4 $TEADATAFILE
# A simple accounting mechanism
#
#prehook_accounting : echo $TEAPRINTERNAME $TEAJOBID $TEAUSERNAME $TEABILLING `pkpgcounter $TEADATAFILE` >>/var/log/printaccounting.log
# Some additionnal hooks to forbid duplicate jobs :
# The prehook will use the history file to filter out duplicate jobs
# checkdupes is an hypothetical command which exits -1 if the current print
# job is a duplicate (same MD5 sum already found in history).
#
# NB : Beware of some software which embed the job printing time into the
# PostScript job : two identical jobs may have different MD5 checksums
# if they differ only by the value of the '%%CreationDate:' PostScript
# comment !
#
#prehook_to_filter_duplicates : /usr/local/bin/checkdupes $TEAMD5SUM /tmp/jobmd5sums
#posthook_to_filter_duplicates : echo "$TEAJOBID : $TEAMD5SUM" >>/tmp/jobmd5sums
# A particular prehook can send datas to the posthook
# of the same name automatically through pipes :
# The file /tmp/result1 will contain the output of prehook_dialog1
# prehook_dialog1 : echo "This is pipe #1"
# posthook_dialog1 : cat >/tmp/result1
# The file /tmp/result2 will contain the output of prehook_dialog2
# prehook_dialog2 : echo "This is pipe #2"
# posthook_dialog2 : cat >/tmp/result2