Repository URL to install this package:
|
Version:
2.58-1 ▾
|
#! /bin/bash
#
# tpfilter - line printer input filter for turboprint driver system
#
# Copyright 2000,2001 ZEDOnet
# Version for raw queues
# Created 6.11.2001
# 5.12.2001 raw output to device fixed
#
PATH=/bin:/usr/bin:/usr/local/bin
PATH=${PATH}:/usr/bin/TeX:/usr/X11R6/bin
PATH=${PATH}:/sbin:/usr/sbin
#export PATH
# get Turboprint paths
eval $(cat "/etc/turboprint/system.cfg")
LOGFILE="$TPPATH_LOG/turboprint/print.log"
TPSTDIN="$TPPATH_FILTERS/tpstdin"
SMBPRINT="$TPPATH_FILTERS/smbprint"
SOCKETPRINT="$TPPATH_FILTERS/socketprint"
NCPPRINT="$TPPATH_FILTERS/ncpprint"
echo >> $LOGFILE || LOGFILE="/dev/null"
echo "-----------------------------" >> $LOGFILE
echo "Raw print job $(date) - command line:" >> $LOGFILE
echo $* >> $LOGFILE
# parse parameters
# lpr:
# -c -wwidth -llength -iident -n login -h host acct-file
# LPRng:
# -Ffileformatcharacter -ejobdatafile -kcontrolfile
# -Hhost -Jjob -Llogin -Pprintername -Qqueue -aacct-file -dspooldir -fjobfilename
# -hhost -jjobnumber -llength -nlogin -wwidth -xxpos -yypos acct-file
# -c means transmit file unchanged ("raw") to printer
#
while [ -z "${1%%-*}" -a -n "$1" ] ; do
temp="${1#-}"
shift
case "$temp" in
a*) # account file (lprng)
{
ACCOUNTFILE="${temp#?}"
};;
e*) # data file (lprng)
{
DATAFILE="${temp#?}"
};;
f*) # job name (lprng)
{
JOBFILE="${temp#?}"
};;
h*) # host name
{
HOST="${temp#?}"
if [ -z "$HOST" ] ; then
HOST="$1"; shift
fi
};;
j*) # job name (lpr) or number (lprng)
{
JOB="${temp#?}"
if [ -z "$JOB" ] ; then
JOB="$1"; shift
fi
};;
n*) # login name
{
LOGIN="${temp#?}"
if [ -z "$LOGIN" ] ; then
LOGIN="$1"; shift
fi
};;
*);; # other flags: ignore
esac
done
# account file set by -a or is last parameter
if [ -z "$ACCOUNTFILE" ] ; then
eval temp="\${$#}"
if [ -n "$temp" -a "$temp" != "$0" ]; then
ACCOUNTFILE="$temp"
fi
unset temp
fi
# job name set by -f (lprng) or -j (lpr)
if [ $JOBFILE ] ; then
JOB="$JOBFILE"
fi
# the spool path is the path to the account file
SPOOLPATH=$(dirname $ACCOUNTFILE)
# the configuration name is the last part the spool path
CONFIGNAME=$(basename $SPOOLPATH)
# the configfile is in the spool directory without "raw"
SPOOLPATH=${SPOOLPATH%%raw}
CONFIGNAME=${CONFIGNAME%%raw}
CONFIGFILE=$SPOOLPATH/tpprinter.cfg
echo "configfile is $CONFIGFILE" >> $LOGFILE
eval $(cat $CONFIGFILE)
# select output filter for printing to a remote printer
echo "output=$REMOTEOUTPUT" >> $LOGFILE
remote="remote"
OUTPUTFILTER=""
case $REMOTEOUTPUT in
device)
{
# no output filter needed
OUTPUTFILTER="cat";
};;
file)
{
OUTPUTFILTER="cat > $PRINTTOFILE";
};;
remote)
{
# lpr queue on other unix machine
# the "old" bsd lpr doesn't filter remote output, so
# output is redirected to a second queue - the remote queue
LPROPTIONS="-P$CONFIGNAME$remote"
if [ $LOGIN ]; then
LPROPTIONS="$LPROPTIONS -U '$LOGIN'"
fi
OUTPUTFILTER="lpr $LPROPTIONS";
};;
smb)
{
# print to a Windows machine via SAMBA
# handled by the smbprint script
# configfile with server name, printer name, etc.
# is passed on to this script
OUTPUTFILTER="$SMBPRINT $CONFIGFILE";
};;
socket)
{
# print to a network printer or server box port
# handled by the socketprint script
# configfile with server name, port number
# is passed on to this script
OUTPUTFILTER="$SOCKETPRINT $CONFIGFILE";
};;
ncp)
{
# *** NOT YET TESTED ***
# print to a Netware server via SAMBA
# handled by the ncpprint script
# configfile with server name, printer name, etc.
# is passed on to this script
OUTPUTFILTER="$NCPPRINT $CONFIGFILE";
};;
esac
# end of output filter selection
# execute output filter
echo "outputfilter is $OUTPUTFILTER" >> $LOGFILE
eval $OUTPUTFILTER
echo "------- end of print job --------" >> $LOGFILE
exit 0