#! /bin/sh # addnetprinter - add a new CAP AppleTalk network printer to Unix system # Rex Sanders, USGS Pacific Marine Geology, 26 December 1991 # heavily modified 8 October 1993, RS # # US Government work in the public domain - NOT copyrighted # # Check out printcap section at end for local printcap options # Change these lines to fit local conditions - # # Add CAP bin directory to local path, for getzones & atlooklws PATH=$PATH:/usr/local/cap/bin # Directory for printer log files LOGDIR=/var/adm # Directory for printer spool, e.g. /var/spool/laserwriter/ SPOOLDIR=/var/spool # Location of cap.printers file (see CAP manuals) CAPRINT=/usr/local/cap/etc/cap.printers # Location of printcap file PRINTCAP=/etc/printcap # Location of PS directory from TranScript PSDIR=/usr/local/lib/ps trap 'rm -f /tmp/anp.$$; exit 1' 1 2 15 echo "addnetprinter - add a new AppleTalk network printer" (echo echo "Choose a zone, by number:" echo getzones | sort > /tmp/anp.$$ cat -n /tmp/anp.$$ echo ) | ${PAGER-more} echo -n "Pick a number (1-"`cat /tmp/anp.$$ | wc -l`") ? " read number zone=`sed -n -e "$number p" /tmp/anp.$$` (echo echo "Choose a printer in \""$zone"\", by number:" echo atlooklws -k "@$zone" | \ grep ' \[Net\:' | \ sed -e 's/:LaserWriter@.*//' -e 's/^......//' | \ sort > /tmp/anp.$$ cat -n /tmp/anp.$$ echo ) | ${PAGER-more} echo -n "Pick a number (1-"`cat /tmp/anp.$$ | wc -l`") ? " read number pname=`sed -n -e "$number p" /tmp/anp.$$` rm /tmp/anp.$$ echo echo "Enter a short Unix print queue name for \"$pname\"" echo "Example: a230" echo echo -n "Queue name: " read qname echo echo "Enter a comment describing \"$qname\"" echo "Example: Apple LaserWriter II NTX near A-230" echo echo -n "Comment: " read comment echo echo "Full name: ${pname}@${zone}" echo "Queue name: $qname" echo "Comment: $comment" echo echo -n "Ready to modify directories and files (y/n) [y] ? " read yn if [ "$yn" = "n" -o "$yn" = "no" ] then exit 1 fi echo "Create printer log file: ${LOGDIR}/${qname}-log ..." touch ${LOGDIR}/${qname}-log chown daemon.daemon ${LOGDIR}/${qname}-log chmod 644 ${LOGDIR}/${qname}-log echo "Create spool directory ${SPOOLDIR}/${qname} and files..." mkdir ${SPOOLDIR}/${qname} chown daemon.daemon ${SPOOLDIR}/${qname} chmod 755 ${SPOOLDIR}/${qname} touch ${SPOOLDIR}/${qname}/.lock chown daemon.daemon ${SPOOLDIR}/${qname}/.lock chmod 644 ${SPOOLDIR}/${qname}/.lock echo "PRINTER=${qname}" > ${SPOOLDIR}/${qname}/.options echo "PSTEXT=${PSDIR}/pstext" >> ${SPOOLDIR}/${qname}/.options echo "export PRINTER PSTEXT" >> ${SPOOLDIR}/${qname}/.options chown daemon.daemon ${SPOOLDIR}/${qname}/.options chmod 644 ${SPOOLDIR}/${qname}/.options echo "Add entry to $CAPRINT ..." echo "${qname}=${pname}:LaserWriter@${zone}" >> $CAPRINT echo "Add entry to $PRINTCAP ..." echo "#" >> $PRINTCAP echo "# $comment" >> $PRINTCAP echo "${qname}|${pname}@${zone}:\\" >> $PRINTCAP echo " :lp=${SPOOLDIR}/${qname}/.lock:sd=${SPOOLDIR}/${qname}:lf=${LOGDIR}/${qname}-log:\\" >> $PRINTCAP echo " :mx#0:sf:sb:sh:rs:\\ :if=${PSDIR}/psif:\\ :of=${PSDIR}/psof:gf=${PSDIR}/psgf:\\ :nf=${PSDIR}/psnf:tf=${PSDIR}/pstf:\\ :rf=${PSDIR}/psrf:vf=${PSDIR}/psvf:" >> $PRINTCAP echo "Done."