Subject: [netatalk-admins] Printing from Solaris to AppleTalk printers

From: "David S." <[email-masked]>
Date: Mon, 13 Apr 1998 12:05:15 -0700 (PDT)

If anyone out there is still having trouble configuring his Solaris system to 
use AppleTalk printers, the script below - which I hacked from one in the 
'cap60' distribution called 'add_at_printer' - worked for me.  I've only tried 
it with 'netatalk-971027' and Solaris 2.6, but I bet it'll work for earlier 
versions of Solaris.

(I also modified the 'lp2pap.sh' script that came with 'netatalk', changing the 
line
	$ATALKHOME/bin/pap "$6"
to
	$ATALKHOME/etc/filters/ofpap < "$6" > /dev/null 2>&1
to get postscript conversion.)

To use the script, edit the 'ATALKHOME' value accordingly, and, as 'root', 

	add_at_printer <AppleTalk printer name> <Unix printer name>
	
where "AppleTalk printer name" is the one returned by 'nbplkup', and "Unix 
printer name" is whatever you want the printer known by on your Unix box.

The original 'cap60' script was somewhat more elaborate; I cut out what I 
thought was the unnecessary stuff.  If you'd like to see that original, drop me 
a line and I'll send it along.

David Simas
[email-masked]

#!/bin/sh

ATALKHOME=/mnt/tools/atalk

ATPRINTER=$1
UXPRINTER=$2

if [ ! -r /etc/lp/filter.table ]; then
	echo "Initializing of default printer filters..."
	for f in `ls /etc/lp/fd | sed 's/.fd$//'`; do
		lpfilter -f $f -F/etc/lp/fd/$f.fd
	done
fi

if lpfilter -f atalk -l > /dev/null 2>&1; then
	echo "AppleTalk printer filter is already defined."
else
	echo "Defining AppleTalk printer filter ..."
	cat > /etc/lp/fd/atalk.fd << EOF

Input types: postscript
Output types: PS
Printer types: AppleTalk
Printers: any
Filter type: slow
Command: /usr/bin/cat
EOF
	lpfilter -f atalk -F /etc/lp/fd/atalk.fd
fi

if [ ! -f /usr/share/lib/terminfo/A/AppleTalk ]; then
	echo "Defining terminfo for AppleTalk printers ..."
	cat > /var/tmp/terminfo << EOF
AppleTalk,
	cols#80, lines#66,
	cpi=null, csnm=^D, lpi=null, scs=^D, slines=^D, u9=^D,
EOF
	tic /var/tmp/terminfo
        rm /var/tmp/terminfo
fi

LOCKSDIR=/var/spool/lp/tmp/AppleTalk
if [ ! -d $LOCKSDIR ]; then
	mkdir -m 0771	$LOCKSDIR
	chown lp	$LOCKSDIR
	chgrp lp	$LOCKSDIR
fi
PSEUDODEVICE=$LOCKSDIR/$UXPRINTER
touch		$PSEUDODEVICE
chown lp	$PSEUDODEVICE
chgrp lp	$PSEUDODEVICE
chmod 0600	$PSEUDODEVICE

echo "(Re)defining $UXPRINTER ..."
(	lpadmin -p $UXPRINTER -D "$UXPRINTER" \
		-T AppleTalk \
		-v $PSEUDODEVICE \
		-I PS \
		-i $ATALKHOME/etc/lp2pap.sh \
		-A none && \
        echo $ATPRINTER > /etc/lp/printers/$UXPRINTER/.paprc
        chown lp /etc/lp/printers/$UXPRINTER/.paprc
        chgrp lp /etc/lp/printers/$UXPRINTER/.paprc
	accept $UXPRINTER && \
	enable $UXPRINTER \
) || exit