+++ /dev/null
-#! /bin/sh
-#
-# $Id: add_netatalk_printer,v 1.7 2003-02-23 03:16:34 srittau Exp $
-#
-# A lovely script to add netatalk printers
-#
-#ident "@(#)netatalk 0.5 99/06/22 job@uchicago.edu" /* Netatalk 1.4*/
-#
-# This File is released under the Perl Artistic Licence.
-# See http://www.perl.org for details
-#
-# Or you can use it under the licence that accompanies Netatalk 1.3 =)
-#
-# This file is maintained by Job Bogan <job@uchicago.edu>
-# Please contact me at this address for bug reports, problems, etc.
-# Please do not bother the netatalk maintainers with problems from
-# this program.
-#
-#
-#
-# Exit Codes ... 1 for missed path or user input
-# 2 for an aborted run (by not saying yes to a 'are you sure?'
-# 3 for failed lpadmin commands
-# 4 for possible security problem
-
-# make base name for temp files.
-
-TMP_STUFF="/tmp/`basename $0`.$$"
-export TMP_STUFF
-rm -rf ${TMP_STUFF}
-mkdir -m 700 ${TMP_STUFF} || exit 4
-trap 'rm -f $TMP_STUFF > /dev/null 2>&1' 0
-trap 'exit' 1 2 3
-
-# grab the pathname the script was called w/
-# if it was run by ./add... then make the path == `pwd`
-
-RUNHOME=`dirname $0`
-
-if [ "$RUNHOME" = "." ]; then
- RUNHOME=`pwd`
-fi
-
-# allow for the env NETATALKHOME to override the guessed one from above
-
-NETATALKHOME=${NETATALKHOME:-$RUNHOME}
-export NETATALKHOME
-
-PATH=/bin:${PATH}:${NETATALKHOME}/bin:${NETATALKHOME}/etc:${NETATALKHOME}/libexec:/usr/lib:/usr/sbin
-
-if [ ! -x ${NETATALKHOME}/bin/pap ]; then
- echo "OOPS: I don't see ${NETATALKHOME}/bin/pap ,"
- echo ' Check that it is executable or set ${NETATALKHOME}'
- echo ' so i can find pap at ${NETATALKHOME}/bin/pap'
- echo '[We are guessing the location of the binary from the'
- echo 'path that was used to run this script or $NETATALKHOME]'
- exit 1
-fi
-
-# get the user to tell us where to look for things, and list things there.
-
-echo ''
-echo "Enter Appletalk zone [default: local]: \c"
-
-read ZONE
-
-echo ""
-echo "Looking for LaserWriters in Zone ${ZONE} ..."
-${NETATALKHOME}/bin/nbplkup ":LaserWriter@${ZONE}"
-
-echo ""
-echo "Enter AppleTalk printer name: \c"
-
-read DEST
-
-if [ "$DEST" = "" ]; then
- echo "OOPS: you need to tell me a printer name"
- exit 1
-fi
-
-echo "checking nbplkup ${DEST}:LaserWriter@${ZONE}"
-echo ""
-TestDEST=`${NETATALKHOME}/bin/nbplkup "${DEST}:LaserWriter@${ZONE}"`
-echo "${TestDEST}"
-echo ""
-
-if [ "${TestDEST}" = "" ]; then
- echo "I don't see that printer on the network. You may have entered an incorrect"
- echo "printer name - if so, exit and restart."
- echo "[You should only enter the printer name, not the :LaserWriter portion]"
- sleep 3
-fi
-
-unset TestDEST
-
-NBPNAME="${DEST}@${ZONE}"
-
-echo ""
-echo ""
-
-# scrunch all of the whitespace and / out of the appletalk name and suggest
-# that as the unix name
-
-SUGGEST=`echo "$DEST" | cut -d: -f1 | sed 's/ //g' | sed 's#/##g` ; export SUGGEST
-
-# truncate the suggested name to 14 chars to conform to lp specs.
-
-SUGGEST1=`expr ${SUGGEST} : '\(..............\)'`
-SUGGEST=${SUGGEST1:-$SUGGEST}
-
-echo "Enter Unix printer name - [default: ${SUGGEST}] : \c"
-read UNIXPRINT
-echo ''
-if [ "${UNIXPRINT}" = "" ]; then
- UNIXPRINT="${SUGGEST}"
-fi
-export UNIXPRINT
-
-#####
-# Here we check for legal names again. >14 chars
-#####
-
-UNIXPRINT1=`expr "${UNIXPRINT}" : '\(..............\)'`
-
-# if UNIXPRINT is shorter than 14chars, UNIXPRINT1 ends up null ("")
-# if UNIXPRINT was longer, then we get a 14char version of it. bleah.
-
-if [ "${UNIXPRINT1}" = "" ]; then
- UNIXPRINT1="${UNIXPRINT}"
-else
-#if [ "${UNIXPRINT1}" != "${UNIXPRINT}" ]; then
- echo "Oops, that name was too long... Truncating to 14 chars."
- echo "setting printer name to '${UNIXPRINT}'"
- UNIXPRINT="${UNIXPRINT1}"
-fi
-
-echo "Enter a description for this printer. [The Appletalk name will"
-echo "be included by default, and must be included for the printing"
-echo "filters to work.] : \c"
-read DESC
-
-DESC="${DESC} [${NBPNAME}]"
-
-echo ""
-echo "Do you want all print jobs to print out in reversed page order?"
-echo "This is usually only desired if this printer stacks jobs"
-echo "face up in the output bin. [N/y] \c"
-read REV
-case ${REV} in [Yy]*) REV="Netatalk-R" ;;
- *) REV="Netatalk" ;;
-esac
-export REV
-
-if lpstat -p ${UNIXPRINT} >/dev/null 2>&1 ; then
- echo '\a'
- echo "OOPS: There already exists a printer named '${UNIXPRINT}'"
- echo " here are the comments from /etc/lp/printers/${UNIXPRINT}/comment"
- cat /etc/lp/printers/${UNIXPRINT}/comment
- echo ""
- echo "Do you still want to do this? This will flush "
- echo "all pending jobs! [Y/n]? \c"
- read DOTHIS
- case ${DOTHIS} in [Yy]*) ;;
- *) exit 2 ;;
- esac
-
- echo "Rejecting all new jobs for ${UNIXPRINT}"
- reject -r "Making ${UNIXPRINT} a netatalk printer" ${UNIXPRINT}
- echo "Disabling and Flushing the ${UNIXPRINT} queue"
- disable -c -r "Making ${UNIXPRINT} a netatalk printer" ${UNIXPRINT}
-fi
-
-#####
-# Check if we need to do silly tricks to share the printer... only on 5.5.1 or older
-#####
-
-if [ "`uname -r`" -lt "5.6" ]; then
- echo ""
- echo "Do you want to share this printer with other machines [Y/n]?\c"
- read SHARE
-else
- echo "You're running SunOS 5.6 or higher... skipping 'sacadm' and 'pmadm'"
-fi
-
-if nistest printers.org_dir; then
- echo "Do you want to add this printer to your NIS printer map? [y/N]"
- echo "(You will need to share this printer with other machines)"
- read NIS
- case ${NIS} in [Yy]*) ADD_NIS=1 ;;
- *) ;;
- esac
-fi
-
-echo "Do you want to save the error messages from pap in"
-echo "'/var/spool/lp/tmp/Netatalk/${UNIXPRINT}' [y/N]"
-echo "(If you answer N, error messages will go to /dev/null.)"
-read SAVEerr
-case ${SAVEerr} in [Yy]*) SAVEerr=1 ;;
- *) unset SAVEerr ;;
-esac
-
-echo "Making ${UNIXPRINT} print to ${DEST} via netatalk"
-
-if [ "${SAVEerr}" = "" ]; then
- LOCKDEV=/dev/null
-else
- LOCKS=/var/spool/lp/tmp/Netatalk
- if [ ! -d ${LOCKS} ]; then
- mkdir -m 0771 ${LOCKS}
- chown lp ${LOCKS}
- chgrp lp ${LOCKS}
- fi
- LOCKDEV=${LOCKS}/${UNIXPRINT}
- touch ${LOCKDEV}
- chown lp:lp ${LOCKDEV}
- chmod 600 ${LOCKDEV}
-fi
-
-echo ""
-
-if [ ! -r /etc/lp/filter.table ]; then
- echo "Setting up the existing print filters..."
- for i in `ls /etc/lp/fd | sed 's/.fd$//'`; do
- lpfilter -f ${i} -F/etc/lp/fd/${i}.fd
- done
-fi
-if lpfilter -f netatalk -l > /dev/null 2>&1 ; then
- echo 'Looks like you have a Netatalk printer filter defined. Good!'
-else
- echo "Humm... You need a Netatalk printer filter..."
- echo "... making you one ..."
- cat > /etc/lp/fd/netatalk.fd << EOF
-#ident "@(#)netatalk.fd 0.2 97/09/04 job@uchicago.edu" /* Netatalk 1.4 */
-
-Input types: postscript
-Output types: PS
-Printer types: Netatalk
-Printers: any
-Filter type: fast
-Command: ${NETATALKHOME}/libexec/ifpap 2>&1 > /dev/null
-EOF
- chown lp:lp /etc/lp/fd/netatalk.fd
- chmod 664 /etc/lp/fd/netatalk.fd
- lpfilter -f netatalk -F /etc/lp/fd/netatalk.fd
-fi
-
-if lpfilter -f netatalk-r -l 2>&1 > /dev/null ; then
- echo 'Looks like you have a Reverse Netatalk printer filter defined. Good!'
-else
- echo "Humm... You need a Reverse Netatalk printer filter..."
- echo "... making you one ..."
- cat > /etc/lp/fd/netatalk-r.fd << EOF
-#ident "@(#)netatalk-r.fd 0.2 97/09/04 job@uchicago.edu" /* Netatalk 1.4 */
-
-Input types: postscript
-Output types: PS
-Printer types: Netatalk-R
-Printers: any
-Filter type: fast
-Command: "/usr/lib/lp/postscript/postreverse | ${NETATALKHOME}/libexec/ifpap 2>&1 >/dev/null"
-EOF
- chown lp:lp /etc/lp/fd/netatalk-r.fd
- chmod 664 /etc/lp/fd/netatalk-r.fd
- lpfilter -f netatalk-r -F /etc/lp/fd/netatalk-r.fd
-fi
-
-if [ ! -r /usr/share/lib/terminfo/N/Netatalk ]; then
- echo "Making a Terminfo entry for Netatalk printers"
- cat > ${TMP_STUFF}/terminfo << EOF
-Netatalk,
- cols#80, lines#66,
- cpi=null, csnm=^D, lpi=null, scs=^D, slines=^D, u9=^D,
-EOF
- tic ${TMP_STUFF}/terminfo
- chown bin:bin /usr/share/lib/terminfo/N/Netatalk
- chmod 644 /usr/share/lib/terminfo/N/Netatalk
-fi
-
-if [ ! -r /usr/share/lib/terminfo/N/Netatalk-R ]; then
- echo "Making a Terminfo entry for Reversed Netatalk printers"
- cat > ${TMP_STUFF}/terminfoR << EOF
-Netatalk-R,
- cols#80, lines#66,
- cpi=null, csnm=^D, lpi=null, scs=^D, slines=^D, u9=^D,
-EOF
- tic "${TMP_STUFF}/terminfoR"
- chown bin:bin /usr/share/lib/terminfo/N/Netatalk-R
- chmod 644 /usr/share/lib/terminfo/N/Netatalk-R
-fi
-
-###
-# this is old cruft... we should not have done this in the 1st place.
-# we need to edit the template interface file to point to the local netatalk bins
-#cat ${RUNHOME}/etc/netatalk.template | sed "s#DEFAULT_NETATALK_HOME#${RUNHOME}#g" \
-# > "/etc/lp/interfaces/${UNIXPRINT}"
-#chown lp:lp /etc/lp/interfaces/${UNIXPRINT}
-#chmod 0775 /etc/lp/interfaces/${UNIXPRINT}
-# below is the correct way.
-###
-
-echo "Setting up ${UNIXPRINT} ... Edit options later as you see fit."
-lpadmin -p ${UNIXPRINT} -D "${DESC}" -T ${REV} \
- -i ${RUNHOME}/netatalk.template -I PS -v ${LOCKDEV} -A none || exit 3
-accept ${UNIXPRINT} || exit 3
-enable ${UNIXPRINT} || exit 3
-
-case ${SHARE} in [Nn]*) exit; ;;
- *) ;;
-esac
-
-echo "Setting up network sharing for ${UNIXPRINT}"
-
-# from p925 in the Solaris Administration Guide, Vol. II (2.5)
-
-echo ""
-if sacadm -l -p tcp > /dev/null; then
- echo "already running a tcp listener"
-else
- echo "Defining tcp listener ..."
- sacadm -a -p tcp -t listen -c "/usr/lib/saf/listen tcp" \
- -v `nlsadmin -V` -n 999
-fi
-
-# this is extra, but a good idea...
-
-LPD_ADDR="\\x`lpsystem -A`" ; export LPD_ADDR
-ADDR_0=`echo $LPD_ADDR | sed -e 's/\\x00020203/\\x00020ACE/g'`; export ADDR_0
-
-if pmadm -l -p tcp -s 0 > /dev/null; then
- echo "<0> service is already defined."
-else
- echo "Defining <0>/tcp service ..."
- pmadm -a -p tcp -s 0 -i root \
- -m `nlsadmin -c /usr/lib/saf/nlps_server -A ${ADDR_0}` \
- -v `nlsadmin -V`
-fi
-
-# again from the solaris book noted above.
-
-if pmadm -l -p tcp -s lp > /dev/null; then
- echo "<lp> service is already defined."
-else
- echo "Defining <lp>/tcp service ..."
- pmadm -a -p tcp -s lp -i root \
- -m `nlsadmin -o /var/spool/lp/fifos/listenS5` \
- -v `nlsadmin -V`
-fi
-
-if pmadm -l -p tcp -s lpd > /dev/null; then
- echo "<lpd> service is already defined."
-else
- echo "Defining <lpd>/tcp service ..."
- pmadm -a -p tcp -s lpd -i root \
- -m `nlsadmin -o /var/spool/lp/fifos/listenBSD -A ${LPD_ADDR}` \
- -v `nlsadmin -V`
-fi
-
-if [ "${ADD_NIS}" = 1 ] ; then
- if nistest "[printer_name=${UNIXPRINT}]printers.org_dir"; then
- nistbladm -m printer_host=`uname -n` \
- "[printer_name=${UNIXPRINT}]printers.org_dir" description="$DESC"
- else
- nistbladm -a printer_name=${UNIXPRINT} \
- description="$DESC" printer_host=`uname -n` printers.org_dir
- fi
-fi
+++ /dev/null
-#ident "@(#)netatalk 0.7 99/06/22 job@uchicago.edu" /* Netatalk 1.4*/
-
-#####
-# User configuration:
-#
-# Set timeout for pap($time) and papstatus($time2). both are in seconds.
-# extraneous if you do not have NETATALKHOME/bin/timeout
-# set how many times to loop before we just abort entirely ($attempts)
-# what flags pap is run w/. -c makes pap claim to have been waiting forever
-#####
-
-time=1800
-time2=60
-attempts=3
-pap_flags="-c"
-
-#####
-# this should get "fixed" to something like
-# NETATALKHOME=/opt ; export NETATALKHOME
-# by the add_netatalk_printer script
-#
-# DO NOT use the user's env for this or the PATH above.
-#####
-
-NETATALKHOME=DEFAULT_NETATALK_HOME ; export NETATALKHOME
-#NETATALKHOME=/opt ; export NETATALKHOME
-
-if [ "${NETATALKHOME}" = "DEFAULT_NETATALK_HOME" ]; then
- echo "bleah, NETATALKHOME not set, exiting..." ; exit 5
-fi
-
-#####
-# BUGS/TODO:
-# move all TMP stuff to use a directory for security reasons
-# run nbplkup to check if the reason we cannot print, is that it's not on
-# the net
-# move to "${foo}" from $foo and ${foo}
-# add debuging info that gets sent to "logger lpd.debug"
-# if we timeout while printing the banner page, we do not keep trying to print.
-# perhaps filter_timeout should only complain once per job; like badfile.
-# check if the timeout messages are duplicated by the lp system
-# psa will not drop in for pap to use accting. perhaps lp does not need it?
-# make pap print all the files at once; kill for file in ($files)
-# move badfile error to printfile function
-#####
-
-# This File is released under the Perl Artistic Licence.
-# See http://www.perl.org for details
-#
-# Or you can use it under the licence that accompanies Netatalk 1.3 =)
-
-###########
-## Netatalk printer interface. Heavily modified from
-## /usr/lib/lp/model/standard on Sparc Solaris 2.5.1 (May 97)
-##
-## Meant to be used w/ add_netatalk_printer
-###########
-
-#####
-# This program is invoked as
-#
-# ${SPOOLDIR}/.../printer request-id user title copies options files...
-#
-# The first three arguments are simply reprinted on the banner page,
-# the fourth (copies) is used to control the number of copies to print,
-# the fifth (options) is a blank separated list (in a single argument)
-# of user or Spooler supplied options (without the -o prefix),
-# and the last argument(s) is/are the file(s) to print.
-#####
-
-#####
-#
-# The protocol between the interface program and the Spooler
-# is fairly simple:
-#
-# All standard error output is assumed to indicate a
-# fault WITH THE REQUEST. The output is mailed to the
-# user who submitted the print request and the print
-# request is finished.
-#
-# If the interface program sets a zero exit code,
-# it is assumed that the file printed correctly.
-# If the interface program sets a non-zero exit code
-# less than 128, it is assumed that the file did not
-# print correctly, and the user will be notified.
-# In either case the print request is finished.
-#
-# If the interface program sets an exit code greater
-# than 128, it is assumed that the file did not print
-# because of a printer fault. If an alert isn't already
-# active (see below) one will be activated. (Exit code
-# 128 should not be used at all. The shell, which executes
-# this program, turns SIGTERM, used to kill this program
-# for a cancellation or disabling, into exit 128. The
-# Spooler thus interpretes 128 as SIGTERM.)
-#
-# A message sent to the standard input of the ${LPTELL}
-# program is assumed to describe a fault WITH THE PRINTER.
-# The output is used in an alert (if alerts are defined).
-# If the fault recovery is "wait" or "begin", the printer
-# is disabled (killing the interface program if need be),
-# and the print request is left on the queue.
-# If the fault recovery is "continue", the interface program
-# is allowed to wait for the printer fault to be cleared so
-# it can resume printing.
-#
-#####
-
-###########################################################################
-#
-# Set up the basic traps. and other important things
-#
-###########################################################################
-
-#####
-# For the time being, just exit if we are poked.
-#####
-
-# SIGTERM handler
-
-trap 'exit' 15
-
-#####
-# We can be clever about getting a hangup or interrupt, though, at least
-# until the filter runs. Do this early, even though $LPTELL
-# isn't defined, so that we're covered.
-#####
-
-trap 'catch_hangup; exit_code=129 exit 129' 1
-trap 'catch_interrupt; exit_code=129 exit 129' 2 3
-
-#####
-# VARIBLE DECLARED - put here so we don't ever run the trap below w/o
-# TMPPREFIX defined. We hard code /tmp for the moment, but fix that later
-#
-# Use ${TMPPREFIX} as the prefix for all temporary files, so
-# that cleanup is easy. The prefix may be up to 13 characters
-# long, so you only have space for one more character to make
-# a file name. If necessary, make a directory using this prefix
-# for better management of unique temporary file names.
-#####
-
-TMPPREFIX=/tmp/`uname -n`$$
-
-#####
-# Before exiting, set ${exit_code} to the value with which to exit.
-# Otherwise, the exit from this script will be 0.
-#####
-
-trap 'rm -fr ${TMPPREFIX}*; exit ${exit_code}' 0
-
-catch_hangup () {
- if [ -n "${LPTELL}" ]
- then
- echo \
- "Humm, we got a SIGHUP. Not sure what it means, but... we'll keep going anyway" \
- | ${LPTELL} "${printer}"
- fi
- return 0
-}
-
-catch_interrupt () {
- if [ -n "${LPTELL}" ]
- then
- echo \
- "Received an interrupt from the printer. The reason is unknown." \
- | ${LPTELL} "${printer}"
- fi
- return 0
-}
-
-#####
-# Most of the time we don't want the standard error to be captured
-# by the Spooler, mainly to avoid "Terminated" messages that the
-# shell puts out when we get a SIGTERM. We'll save the standard
-# error channel under another number, so we can use it when it
-# should be captured.
-#
-# Open another channel to the printer port, for use when the
-# regular standard output won't be directed there, such as in
-# command substitution (`cmd`).
-#####
-
-exec 5>&2 2>/dev/null 3>&1
-
-###########################################################################
-#
-# Define local varibles and such
-#
-###########################################################################
-
-#####
-# There is one more varible set by the shell that execs us.
-# FILTER The filter to run ; we ignore this directive
-#####
-
-#####
-# Use the user set env, or else default to standard values.
-#####
-
-: ${SPOOLDIR:=/usr/spool/lp}
-: ${TMPDIR:=/tmp} ; export TMPDIR
-: ${LOCALPATH:=${SPOOLDIR}/bin} ; export LOCALPATH
-
-PATH="/bin:/usr/bin:${LOCALPATH}:${NETATALKHOME}/bin:${NETATALKHOME}/etc"
-export PATH
-
-TMPPREFIX=${TMPDIR}/`uname -n`$$
-
-#####
-# Error levels for the errmsg() func.
-#####
-
-LP_ERR_LABEL="UX:lp" ; export LP_ERR_LABEL
-
-E_IP_ARGS=1
-E_IP_OPTS=2
-E_IP_UNKNOWN=5
-E_IP_BADFILE=6
-
-#####
-# Error message formatter:
-#
-# Invoke as
-#
-# errmsg severity message-number problem help
-#
-# where severity is "ERROR" or "WARNING", message-number is
-# a unique identifier, problem is a short description of the
-# problem, and help is a short suggestion for fixing the problem.
-#####
-
-errmsg () {
- case $1 in
- ERROR )
- sev=" ERROR";
- ;;
- WARNING )
- sev="WARNING";
- ;;
- esac
- echo "${LP_ERR_LABEL}: ${sev}: $3
- TO FIX: $4" >&5
-}
-
-parse () {
- echo "`expr \"$1\" : \"^[^=]*=\(.*\)\"`"
-}
-
-#####
-# die quickly if we do not have the right number of arguments.
-#####
-
-if [ $# -lt 5 ]
-then
- errmsg ERROR ${E_IP_ARGS} \
- "wrong number of arguments to interface program" \
- "consult your system administrator"
- exit 1
-fi
-
-printer=`basename $0`
-request_id=$1
-
-# this will formated be machine!username, so we want to split that up...
-
-user_name=$2
-machine=`echo $user_name | cut -d! -f1`
-user_name=`echo $user_name | cut -d! -f2`
-
-title=$3
-copies=$4
-option_list=$5
-
-shift 5
-files="$*"
-
-nobanner="yes"
-
-inlist=
-
-for i in ${option_list}
-do
-case "${inlist}${i}" in
- nobanner )
- nobanner="yes" ;;
- banner )
- nobanner="no" ;;
-#####
-#
-# If you want to add simple options (e.g. -o simple)
-# identify them here.
-#####
-# simple )
-# simple="yes" ;;
-
-#####
-# These get ignored, but would matter little anyway since all we see
-# here is PS anyway.
-#####
- cpi=* )
-# cpi=`parse ${i}` ;;
- true ;;
- lpi=* )
-# lpi=`parse ${i}` ;;
- true ;;
- length=* )
-# length=`parse ${i}` ;;
- true ;;
- width=* )
-# width=`parse ${i}` ;;
- true ;;
-
- #####
- # If you want to add simple-value options (e.g. -o value=a)
- # identify them here.
- #####
- #value=* )
- # value=`parse ${i}` ;;
-
- flist=* )
- flist=`parse ${i}` ;;
- input* )
- true ;;
- * )
- errmsg WARNING ${E_IP_OPTS} \
- "unrecognized \"-o ${i}\" option" \
- "check the option, resubmit if necessary
- printing continues" ;;
-
- esac
-done
-
-#####
-# A bit ugly, but grabs the appletalk printer name from the lp system printer
-# description, so it's right up there in admintool. the appletalk name must
-# be delimited by [ and ].
-#
-# eg - 'this is the printer [hp-mrsec-l114:lasershared@Research Insitutes] that i use.'
-#####
-
-PAPDEST="`lpstat -D -p "${printer}" | grep -i descrip | sed 's/.*Description:.*\[//g' | sed 's/\].*//g'`"
-
-export PAPDEST
-
-###########################################################################
-#
-# Define our local functions (parse is declared above option parsing)
-#
-###########################################################################
-
-banner () {
- echo "##### User: ${user_name}"
- echo ""
- echo "##### Machine: ${user_name}"
- echo ""
-
- if [ -n "${title}" ]
- then
- echo "##### Title: ${title}"
- echo ""
- fi
-
- echo "##### Files: ${flist}"
- echo ""
-
-#####
-# this should deal w/ the year 2000 ok. But will die in 2038. =)
-#####
-
- YEAR=`date '+%y'`
- YEAR=`expr 1900 + ${YEAR}`
-
- echo "##### Date: `date '+%a %H:%M %h %d,'` ${YEAR}"
- echo ""
- echo "##### Job: ${request_id}"
- echo ""
-
-}
-
-print_banner() {
- if [ -x ${NETATALKHOME}/bin/timeout ]
- then
- banner | ${NETATALKHOME}/etc/psf \
- | ${NETATALKHOME}/bin/timeout "${time}" ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
- else
- banner | ${NETATALKHOME}/etc/psf \
- | ${NETATALKHOME}/bin/pap -c -p "{PAPDEST}"
- fi
-
- if [ ${?} -ne 0 ]
- then
- filter_timeout
- fi
-}
-
-#####
-# ${LPTELL} is the name of a program that will send its
-# standard input to the Spooler. It is used to forward
-# the description of a printer fault to the Spooler,
-# which uses it in an alert to the administrator.
-#####
-if [ ! -x "${LPTELL:=${LOCALPATH}/lp.tell}" ]
-then
- fake_lptell(){
- header="no"
- while read line
- do
- if [ "no" = "${header}" ]
- then
- errmsg ERROR ${E_IP_UNKNOWN} \
- "unknown printer/interface failure" \
- "consult your system administrator; \
- reasons for failure (if any) follow:"
- header=yes
- fi
- echo "${line}" >&2
- done
- return 1
- }
- LPTELL=fake_lptell
-fi
-
-
-#####
-# timeout catcher for the printing filter
-#####
-
-filter_timeout() {
-
- cat > ${TMPPREFIX}D <<EOF
-
-The printer ${printer} either timed out at ${time} seconds or pap exited
-abnormally. As well, we may have exceeded ${print_tries} print attempts.
-The job ${request_id} from ${user_name} on ${machine} was
-printing when this happened.
-
-It may be that the only problem is the size of the job and the speed
-of the printer.
-
-Here is what $NETATALKHOME/bin/papstatus reports as the current
-state of the printer:
-
-EOF
-#####
-# We don't need to test for timeout, since we cannot get here w/o it.
-#####
-
- ${NETATALKHOME}/bin/timeout ${time2} ${NETATALKHOME}/bin/papstatus -p "${PAPDEST}" 2>&1 >> ${TMPPREFIX}D
- paperr=${?}
-
- errmsg WARNING ${E_IP_UNKNOWN} "`cat ${TMPPREFIX}D`" "printing continues"
-#####
-# This ought to deal w/ the problem of nonexistent appletalk names, but...
-# for the moment, it calls filter_death. But it sends the papstatus
-# info to LPTELL anyhow, so you should be able to see the error.
-#####
-
- if [ ${paperr} -ne 0 -o ${too_many} = "1" ]; then
- paperr=
- filter_death
- fi
- paperr=
- echo "serverdict begin 0 exitserver systemdict /quit get exec" | \
- ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
- return 0
-}
-
-#####
-# Death catcher for filter_timeout
-#####
-
-filter_death() {
-
- cat > ${TMPPREFIX}Z <<EOF
-Excessive delays w/ the printer ${printer}!
-
-While processing on printer ${printer} the job ${request_id}
-from ${user_name} on ${machine} timed out at ${time} seconds.
-
-Then while cleaning that timeout, the cleanup operation failed as
-well.
-
-EOF
- errmsg ERROR ${E_IP_UNKNOWN} "`cat ${TMPPREFIX}Z`"
- exit 129
-#####
-# Exit and fault the printer.
-#####
-}
-
-#####
-# Print the job
-#####
-printfile() {
- trap '' 1 # Let the filter handle a hangup
- trap '' 2 3 # and interrupts
-#####
-# We use timeout so as to not hang the print queue indefinately. (pap does not
-# timeout on it's own.)
-#
-# Put the 0<${files} before the "eval" to keep clever users from giving
-# a file name that evaluates as something to execute.
-#####
- if [ "${TERM}" == "Netatalk-R" ]; then
- if [ -x ${NETATALKHOME}/bin/timeout ]; then
- 0<${file} /usr/lib/lp/postscript/postreverse | ${NETATALKHOME}/bin/timeout ${time} ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
- else
- 0<${file} /usr/lib/lp/postscript/postreverse | ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
- fi
- else
- if [ -x ${NETATALKHOME}/bin/timeout ]; then
- 0<${file} ${NETATALKHOME}/bin/timeout ${time} ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
- else
- 0<${file} ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
- fi
- fi
- paperr=${?}
- print_tries=`expr "${print_tries}" + 1`
- if [ "${paperr}" != "0" -a "${print_tries}" -gt "${attempts}" ]; then
- too_many=1
- fi
- trap 'catch_hangup; exit_code=129 exit 129' 1
- trap 'catch_interrupt; exit_code=129 exit 129' 2 3
- return ${paperr}
-}
-
-#####
-# Some basic sanity checking:
-#####
-
-if [ ! -x $NETATALKHOME/bin/pap ]
-then
- echo "Opps, cannot find $NETATALKHOME/bin/pap, so I don't know how to"
- echo "print things"
- # exit w/ less than 128 to mark an error w/ the job, and call it done
- exit 1
-fi
-
-###########################################################################
-#
-# Start the main section of the program.
-#
-###########################################################################
-
-#####
-# Here i should have a "job canceled" page ready in a trap in case of getting killed
-# but, alas, that would most likely muck up the PS. So we just drop the job on the
-# floor.
-#####
-
-#####
-# If you want a custom banner, change the code up in the functions section.
-#####
-
-if [ "no" = "${nobanner}" -a "${TERM}" != "Netatalk-R" ]
-then
- print_banner
-fi
-
-#####
-# Print some copies of the file(s)
-#####
-
-badfileyet=
-i=1
-while [ $i -le $copies ]
-do
- for file in ${files}
- do
- if [ -r "${file}" ]
- then
- print_tries=0
- until printfile
- do
- filter_timeout;
- done
- else
-#####
-# Don't complain about not being able to read a file on second and
-# subsequent copies, unless we've not complained yet. This removes
-# repeated messages about the same file yet reduces the chance that the
-# user can remove a file and not know that we had trouble finding it.
-#####
- if [ "${i}" -le 1 -o -z "${badfileyet}" ]
- then
- errmsg WARNING ${E_IP_BADFILE} \
- "cannot read file \"${file}\" " \
- "see if the file still exists and is readable by the user\
- lp (or world), or consult your system administrator; \
- We will keep trying to print the other files or copies"
- badfileyet=yes
- fi
- fi
- done
- i=`expr $i + 1`
-done
-
-#####
-# print the banner page if we are a reversed queue
-#####
-if [ "no" = "${nobanner}" -a "${TERM}" == "Netatalk-R" ]
-then
- print_banner
-fi
-
-echo "serverdict begin 0 exitserver systemdict /quit get exec" | \
- ${NETATALKHOME}/bin/pap -c -p "${PAPDEST}"
-
-Exit_code=0 exit 0