17c478bd9Sstevel@tonic-gate#!/bin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*355b4669Sjacobs# Common Development and Distribution License (the "License"). 7*355b4669Sjacobs# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 227c478bd9Sstevel@tonic-gate# 23*355b4669Sjacobs# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate# 287c478bd9Sstevel@tonic-gatePATH=/bin:/usr/bin:/usr/sbin export PATH 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gateTEXTDOMAIN="SUNW_OST_OSCMD" 317c478bd9Sstevel@tonic-gateexport TEXTDOMAIN 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gateLPSET=/usr/bin/lpset 347c478bd9Sstevel@tonic-gateLPGET=/usr/bin/lpget 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gateHOST=`/bin/uname -n` 375c88ba20SwendypLHOST="localhost" 387c478bd9Sstevel@tonic-gatePID=$$ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gatecmd_name=lpadmin 417c478bd9Sstevel@tonic-gateexit_code=0 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gateusage() { 447c478bd9Sstevel@tonic-gate gettext "Usage:\n" 1>&2 457c478bd9Sstevel@tonic-gate gettext " lpadmin -p (printer) (options)\n" 1>&2 467c478bd9Sstevel@tonic-gate gettext " lpadmin -x (dest)\n" 1>&2 477c478bd9Sstevel@tonic-gate gettext " lpadmin -d (dest)\n" 1>&2 487c478bd9Sstevel@tonic-gate gettext " lpadmin -S print-wheel -A alert-type [ -W minutes ]\n" 1>&2 497c478bd9Sstevel@tonic-gate gettext " [ -Q requests ]\n" 1>&2 507c478bd9Sstevel@tonic-gate gettext " lpadmin -M -f form-name [ -a [ -o filebreak ]\n" 1>&2 517c478bd9Sstevel@tonic-gate gettext " [ -t tray-number ]]\n" 1>&2 527c478bd9Sstevel@tonic-gate exit 1 537c478bd9Sstevel@tonic-gate} 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate# 567c478bd9Sstevel@tonic-gate# Delete entries in /etc/printers.conf for local printers/classes that no longer 577c478bd9Sstevel@tonic-gate# exist in the /etc/lp database 587c478bd9Sstevel@tonic-gate# 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gatedelete_local() { 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate# Get printer names for each local printer 637c478bd9Sstevel@tonic-gate# grep /etc/printers.conf for each bsdaddr for this server 647c478bd9Sstevel@tonic-gate# get printer name from that line 657c478bd9Sstevel@tonic-gate 665c88ba20Swendypfor LINE in `/bin/grep bsdaddr /etc/printers.conf | 675c88ba20Swendyp /bin/egrep -e ${HOST}\|${LHOST}` 687c478bd9Sstevel@tonic-gatedo 695c88ba20Swendyp PRINTER=`echo ${LINE} | /bin/sed -e 's/^:bsdaddr='$LHOST',//' \ 705c88ba20Swendyp -e 's/^:bsdaddr='$HOST',//' \ 715c88ba20Swendyp -e 's/[,:].*//'` 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate# If there is not an entry for this printer in 747c478bd9Sstevel@tonic-gate# /etc/lp/printers or /etc/lp/classes 757c478bd9Sstevel@tonic-gate# Then delete the entry for this printer in /etc/printers.conf 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate if [ ! -d /etc/lp/printers/${PRINTER} -a ! -f /etc/lp/classes/${PRINTER} ] ; 787c478bd9Sstevel@tonic-gate then 797c478bd9Sstevel@tonic-gate logger -p lpr.debug -t "lpadmin[${PID}]" \ 807c478bd9Sstevel@tonic-gate "Removing $PRINTER entry from /etc/printers.conf" 817c478bd9Sstevel@tonic-gate ${LPSET} -x ${PRINTER} 827c478bd9Sstevel@tonic-gate status=$? 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate if [ ${status} -ne 0 ] ; then 857c478bd9Sstevel@tonic-gate gettext "Warning: error removing ${PRINTER} " 1>&2 867c478bd9Sstevel@tonic-gate gettext "entry from /etc/printers.conf\n" 1>&2 877c478bd9Sstevel@tonic-gate logger -p lpr.debug -t "lpadmin[${PID}]" \ 887c478bd9Sstevel@tonic-gate "Call to lpset -x $PRINTER exits with ${status}" 897c478bd9Sstevel@tonic-gate exit_code=1 907c478bd9Sstevel@tonic-gate fi 917c478bd9Sstevel@tonic-gate fi 927c478bd9Sstevel@tonic-gatedone 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate# 957c478bd9Sstevel@tonic-gate# shutdown scheduler if there are no local printers 967c478bd9Sstevel@tonic-gate# 977c478bd9Sstevel@tonic-gateCONFIGS=/etc/lp/printers/*/configuration 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gateprinters_configured=`echo $CONFIGS` 1007c478bd9Sstevel@tonic-gateif [ "$printers_configured" = "$CONFIGS" ]; then 1017c478bd9Sstevel@tonic-gate svcprop -q svc:/application/print/server:default && 1027c478bd9Sstevel@tonic-gate svcadm disable svc:/application/print/server:default 1037c478bd9Sstevel@tonic-gatefi 1047c478bd9Sstevel@tonic-gate} 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gatedelete_entries() { 1077c478bd9Sstevel@tonic-gateif [ ! -f /etc/printers.conf ] ; then 1087c478bd9Sstevel@tonic-gate logger -p lpr.debug -t "lpadmin[${PID}]" \ 1097c478bd9Sstevel@tonic-gate "System error: Cannot access /etc/printers.conf" 1107c478bd9Sstevel@tonic-gate gettext "lpadmin: System error; Cannot access /etc/printers.conf\n" 1>&2 1117c478bd9Sstevel@tonic-gate exit 1 1127c478bd9Sstevel@tonic-gatefi 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate# remove _default 1157c478bd9Sstevel@tonic-gate 1165c88ba20SwendypDEFAULTP=`${LPGET} _default | /bin/grep use | /bin/sed -e 's/[ ]*use=//'` 1177c478bd9Sstevel@tonic-gate${LPGET} -k bsdaddr ${DEFAULTP} >/dev/null 2>&1 1187c478bd9Sstevel@tonic-gatestatus=$? 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gateif [ ${status} -eq 0 ] ; then 1217c478bd9Sstevel@tonic-gate ${LPSET} -x _default 1227c478bd9Sstevel@tonic-gate status=$? 1237c478bd9Sstevel@tonic-gate if [ ${status} -ne 0 ] ; then 1247c478bd9Sstevel@tonic-gate gettext "Warning: error removing _default entry from /etc/printers.conf\n" 1>&2 1257c478bd9Sstevel@tonic-gate logger -p lpr.debug -t "lpadmin[${PID}]" \ 1267c478bd9Sstevel@tonic-gate "Call to lpset -x _default exits with ${status}" 1277c478bd9Sstevel@tonic-gate exit_code=1 1287c478bd9Sstevel@tonic-gate fi 1297c478bd9Sstevel@tonic-gatefi 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate# delete entries in /etc/printers.conf for printers/classes that have 1327c478bd9Sstevel@tonic-gate# been deleted 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gatedelete_local 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate# Delete all the remote printers using bsdaddr 1377c478bd9Sstevel@tonic-gate 1385c88ba20Swendypfor LINE in `/bin/grep bsdaddr /etc/printers.conf | /bin/egrep -v -e ${HOST}\|${LHOST}` 1397c478bd9Sstevel@tonic-gatedo 1405c88ba20Swendyp PRINTER=`echo $LINE | /bin/sed -e 's/^:bsdaddr=[^,]*,//' -e 's/[,:].*//'` 1417c478bd9Sstevel@tonic-gate ${LPSET} -x $PRINTER 1427c478bd9Sstevel@tonic-gate status=$? 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate if [ ${status} -ne 0 ] ; then 1457c478bd9Sstevel@tonic-gate gettext "Warning: error removing ${PRINTER} entry from /etc/printers.conf\n" 1>&2 1467c478bd9Sstevel@tonic-gate logger -p lpr.debug -t "lpadmin[${PID}]" \ 1477c478bd9Sstevel@tonic-gate "Call to lpset -x $PRINTER exits with ${status}" 1487c478bd9Sstevel@tonic-gate exit_code=1 1497c478bd9Sstevel@tonic-gate fi 1507c478bd9Sstevel@tonic-gatedone 1517c478bd9Sstevel@tonic-gate} 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gateif [ $# -lt 1 ] ; then 1547c478bd9Sstevel@tonic-gate usage 1557c478bd9Sstevel@tonic-gate exit 1 1567c478bd9Sstevel@tonic-gatefi 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate# Deal with the -d option independently since getopts does not handle 1597c478bd9Sstevel@tonic-gate# options that may or may not have arguments 1607c478bd9Sstevel@tonic-gate# 1617c478bd9Sstevel@tonic-gatefirst=$1 1627c478bd9Sstevel@tonic-gatesecond=$2 1637c478bd9Sstevel@tonic-gatethird=$3 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gateif [ ${first} = "-d" ] ; then 1667c478bd9Sstevel@tonic-gate # check that there are no extra arguments 1677c478bd9Sstevel@tonic-gate if [ -n "${third}" ] ; then 1687c478bd9Sstevel@tonic-gate usage 1697c478bd9Sstevel@tonic-gate exit 1 1707c478bd9Sstevel@tonic-gate fi 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate # be sure we have lpset and lpget 1747c478bd9Sstevel@tonic-gate if [ ! -f ${LPSET} -o ! -f ${LPGET} ] ; then 1757c478bd9Sstevel@tonic-gate gettext "lpadmin: System error; cannot set default printer\n" 1>&2 1767c478bd9Sstevel@tonic-gate exit 2 1777c478bd9Sstevel@tonic-gate fi 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate if [ ! -n "${second}" ] ; then 1807c478bd9Sstevel@tonic-gate ${LPGET} -n system _default >/dev/null 2>&1 1817c478bd9Sstevel@tonic-gate exit_code=$? 1827c478bd9Sstevel@tonic-gate if [ ${exit_code} -eq 0 ] ; then 1837c478bd9Sstevel@tonic-gate # delete _default entry in /etc/printers.conf 1847c478bd9Sstevel@tonic-gate ${LPSET} -n system -x _default 1857c478bd9Sstevel@tonic-gate exit_code=$? 1867c478bd9Sstevel@tonic-gate if [ ${exit_code} -ne 0 ] ; then 1877c478bd9Sstevel@tonic-gate gettext "lpadmin: System error while trying to delete default printer\n" 1>&2 1887c478bd9Sstevel@tonic-gate fi 1897c478bd9Sstevel@tonic-gate else 1907c478bd9Sstevel@tonic-gate # there was no _default, the work is done 1917c478bd9Sstevel@tonic-gate exit_code=0 1927c478bd9Sstevel@tonic-gate fi 1937c478bd9Sstevel@tonic-gate else 1947c478bd9Sstevel@tonic-gate # add/change _default entry in /etc/printers.conf 1957c478bd9Sstevel@tonic-gate ${LPGET} -k bsdaddr ${second} >/dev/null 2>&1 1967c478bd9Sstevel@tonic-gate exit_code=$? 1977c478bd9Sstevel@tonic-gate if [ $exit_code -eq 0 ] ; then 1987c478bd9Sstevel@tonic-gate ${LPSET} -n system -a use=${second} _default 1997c478bd9Sstevel@tonic-gate exit_code=$? 2007c478bd9Sstevel@tonic-gate else 2017c478bd9Sstevel@tonic-gate echo "${second}: " 1>&2 2027c478bd9Sstevel@tonic-gate gettext "undefined printer\n" 1>&2 2037c478bd9Sstevel@tonic-gate fi 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate fi 2067c478bd9Sstevel@tonic-gate exit ${exit_code} 2077c478bd9Sstevel@tonic-gatefi 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate# Strip off legal options 2107c478bd9Sstevel@tonic-gatewhile getopts "A:ac:D:e:f:F:H:hi:I:lm:Mn:o:p:Q:r:S:s:T:u:U:v:W:x:t:P:" arg 2117c478bd9Sstevel@tonic-gatedo 2127c478bd9Sstevel@tonic-gate case $arg in 2137c478bd9Sstevel@tonic-gate D) 2147c478bd9Sstevel@tonic-gate description="${OPTARG}" 2157c478bd9Sstevel@tonic-gate ;; 2167c478bd9Sstevel@tonic-gate p) 2177c478bd9Sstevel@tonic-gate if [ -n "${delete}" ] ; then 2187c478bd9Sstevel@tonic-gate usage 2197c478bd9Sstevel@tonic-gate fi 2207c478bd9Sstevel@tonic-gate printer=${OPTARG} 2217c478bd9Sstevel@tonic-gate ;; 2227c478bd9Sstevel@tonic-gate s) 2237c478bd9Sstevel@tonic-gate server=${OPTARG} 2247c478bd9Sstevel@tonic-gate ;; 2257c478bd9Sstevel@tonic-gate v|U) 2267c478bd9Sstevel@tonic-gate device=${OPTARG} 2275c88ba20Swendyp if [ ! -n "${server}" ] ; then 2285c88ba20Swendyp server=${HOST} 2295c88ba20Swendyp fi 2307c478bd9Sstevel@tonic-gate ;; 2317c478bd9Sstevel@tonic-gate x) 2327c478bd9Sstevel@tonic-gate if [ -n "${printer}" -o -n "${server}" -o \ 2337c478bd9Sstevel@tonic-gate -n "${device}" -o -n "${description}" ] ; then 2347c478bd9Sstevel@tonic-gate usage 2357c478bd9Sstevel@tonic-gate fi 2367c478bd9Sstevel@tonic-gate delete=${OPTARG} 2377c478bd9Sstevel@tonic-gate printer=${OPTARG} 2387c478bd9Sstevel@tonic-gate if [ ${printer} = "all" ] ; then 2397c478bd9Sstevel@tonic-gate local="true" 2407c478bd9Sstevel@tonic-gate fi 2417c478bd9Sstevel@tonic-gate ;; 2427c478bd9Sstevel@tonic-gate S|M|A) 2437c478bd9Sstevel@tonic-gate local="true" 2447c478bd9Sstevel@tonic-gate ;; 2457c478bd9Sstevel@tonic-gate c) 2467c478bd9Sstevel@tonic-gate class=${OPTARG} 2477c478bd9Sstevel@tonic-gate local="true" 2487c478bd9Sstevel@tonic-gate if [ ! -f ${LPGET} ] ; then 2497c478bd9Sstevel@tonic-gate gettext "lpadmin: System error; cannot set class\n " 1>&2 2507c478bd9Sstevel@tonic-gate exit 2 2517c478bd9Sstevel@tonic-gate fi 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate ${LPGET} "${class}" > /dev/null 2>&1 2547c478bd9Sstevel@tonic-gate lpget_class=$? 2557c478bd9Sstevel@tonic-gate if [ ${lpget_class} -eq 0 -a ! -r /etc/lp/classes/"${class}" ] ; then 2567c478bd9Sstevel@tonic-gate gettext "lpadmin: ERROR: Can't create class ${class}.\n" 1>&2 2577c478bd9Sstevel@tonic-gate gettext " TO FIX: This is an existing printer name;\n" 1>&2 2587c478bd9Sstevel@tonic-gate gettext " choose another name.\n" 1>&2 2597c478bd9Sstevel@tonic-gate exit 1 2607c478bd9Sstevel@tonic-gate fi 2617c478bd9Sstevel@tonic-gate ;; 2627c478bd9Sstevel@tonic-gate r) 2637c478bd9Sstevel@tonic-gate pconflocalclean="true" 2647c478bd9Sstevel@tonic-gate local="true" 2657c478bd9Sstevel@tonic-gate ;; 2667c478bd9Sstevel@tonic-gate esac 2677c478bd9Sstevel@tonic-gatedone 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate# 2707c478bd9Sstevel@tonic-gate# We don't have anything to do; let user know and bail 2717c478bd9Sstevel@tonic-gate# 2727c478bd9Sstevel@tonic-gateif [ ! -n "${printer}" -a ! -n "${delete}" -a ! -n "${local}" ] ; then 2737c478bd9Sstevel@tonic-gate gettext "lpadmin: ERROR: Nothing to do.\n" 1>&2 2747c478bd9Sstevel@tonic-gate gettext " TO FIX: You must give one of these options:\n" 1>&2 2757c478bd9Sstevel@tonic-gate gettext " -p, -d, -x -S\n" 1>&2 2767c478bd9Sstevel@tonic-gate exit 1 2777c478bd9Sstevel@tonic-gatefi 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate# 2807c478bd9Sstevel@tonic-gate# Printer does not exist 2817c478bd9Sstevel@tonic-gate# To be consistent with 2.5, assume adding local printer 2827c478bd9Sstevel@tonic-gate# 2837c478bd9Sstevel@tonic-gateif [ ! -n "${device}" -a ! -n "${server}" -a ! -n "${delete}" \ 2847c478bd9Sstevel@tonic-gate -a ! -n "${local}" ] ; then 2857c478bd9Sstevel@tonic-gate ${LPGET} "${printer}" > /dev/null 2>&1 2867c478bd9Sstevel@tonic-gate lpget_stat=$? 2877c478bd9Sstevel@tonic-gate if [ ${lpget_stat} -ne 0 ] ; then 2887c478bd9Sstevel@tonic-gate gettext "lpadmin: ERROR: Missing -U or -v option.\n" 1>&2 2897c478bd9Sstevel@tonic-gate gettext " TO FIX: Local printers must have\n" 1>&2 2907c478bd9Sstevel@tonic-gate gettext " a port defined (-v option) or\n" 1>&2 2917c478bd9Sstevel@tonic-gate gettext " have dial-out instructions (-U option).\n" 1>&2 2927c478bd9Sstevel@tonic-gate exit 1 2937c478bd9Sstevel@tonic-gate fi 2947c478bd9Sstevel@tonic-gatefi 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate# 2977c478bd9Sstevel@tonic-gate# Do the LP configuration for a local printer served by lpsched 2987c478bd9Sstevel@tonic-gate# 2997c478bd9Sstevel@tonic-gateif [ -f /usr/lib/lp/local/$cmd_name ] ; then 3007c478bd9Sstevel@tonic-gate if [ -f /etc/lp/printers/${printer}/configuration -o -n "${device}" -o \ 3017c478bd9Sstevel@tonic-gate -f /etc/lp/classes/${printer} -o -n "${local}" ] ; then 3027c478bd9Sstevel@tonic-gate # to deal with multi-word arguments 3037c478bd9Sstevel@tonic-gate CMD="/usr/lib/lp/local/$cmd_name" 3047c478bd9Sstevel@tonic-gate while [ -n "$*" ] ; do 3057c478bd9Sstevel@tonic-gate CMD="$CMD \"$1\"" 3067c478bd9Sstevel@tonic-gate shift 3077c478bd9Sstevel@tonic-gate done 3087c478bd9Sstevel@tonic-gate case "$CMD" in 3097c478bd9Sstevel@tonic-gate *\"-D\") 3107c478bd9Sstevel@tonic-gate CMD="$CMD \"\"" 3117c478bd9Sstevel@tonic-gate ;; 3127c478bd9Sstevel@tonic-gate esac 3137c478bd9Sstevel@tonic-gate # if adding a printer, make sure scheduler is running 3147c478bd9Sstevel@tonic-gate if [ -n "${printer}" -a ! -n "${delete}" -a \ 3157c478bd9Sstevel@tonic-gate ! -p /var/spool/lp/fifos/FIFO ]; then 3165c88ba20Swendyp svcadm enable -s svc:/application/print/server:default 3177c478bd9Sstevel@tonic-gate fi 3187c478bd9Sstevel@tonic-gate eval $CMD 3197c478bd9Sstevel@tonic-gate exit_code=$? 320*355b4669Sjacobs # add filters to the print server 321*355b4669Sjacobs if [ ! -f /etc/lp/filter.table ] ; then 322*355b4669Sjacobs cd /etc/lp/fd ; for filter in *.fd ; do 323*355b4669Sjacobs /usr/sbin/lpfilter \ 324*355b4669Sjacobs -f `/usr/bin/basename $filter .fd` \ 325*355b4669Sjacobs -F $filter 326*355b4669Sjacobs done 327*355b4669Sjacobs fi 3287c478bd9Sstevel@tonic-gate fi 3297c478bd9Sstevel@tonic-gatefi 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gateif [ $exit_code != 0 ] ; then 3327c478bd9Sstevel@tonic-gate exit $exit_code 3337c478bd9Sstevel@tonic-gatefi 3347c478bd9Sstevel@tonic-gate 335*355b4669Sjacobs# process the "server" value 336*355b4669Sjacobs# It can be a hostname, UUCP form (server!queue), RCMD form(queue@server), 337*355b4669Sjacobs# or in URI form ({scheme}://{endpoint}) 338*355b4669Sjacobs# 339*355b4669Sjacobscase "${server}" in 340*355b4669Sjacobs *://*) # URI form 341*355b4669Sjacobs uri=${server} 342*355b4669Sjacobs rem_printer=`expr "${server}" : ".*://.*/\([^/]*\)"` 343*355b4669Sjacobs server=`expr "${server}" : ".*://\([^/]*\)/.*"` 344*355b4669Sjacobs ;; 345*355b4669Sjacobs *@*) # RCMD form 346*355b4669Sjacobs rem_printer=`expr "${server}" : "\(.*\)@.*"` 347*355b4669Sjacobs server=`expr "${server}" : ".*@\(.*\)"` 348*355b4669Sjacobs ;; 349*355b4669Sjacobs *!*) # UUCP form 350*355b4669Sjacobs rem_printer=`expr "${server}" : ".*!\(.*\)"` 351*355b4669Sjacobs server=`expr "${server}" : "\(.*\)!.*"` 352*355b4669Sjacobs ;; 353*355b4669Sjacobs *) # hostname 3547c478bd9Sstevel@tonic-gate rem_printer=${printer} 355*355b4669Sjacobs ;; 356*355b4669Sjacobsesac 357*355b4669Sjacobs# default URI form is "lpd" form 358*355b4669Sjacobsif [ -n "${server}" ] ; then 359*355b4669Sjacobs uri=${uri:-"lpd://${server}/printers/${rem_printer}#Solaris"} 360*355b4669Sjacobs bsdaddr="${server},${rem_printer},Solaris" 3617c478bd9Sstevel@tonic-gatefi 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate# 3647c478bd9Sstevel@tonic-gate# Do the Solstice Print Configuration in /etc 3657c478bd9Sstevel@tonic-gate# 3667c478bd9Sstevel@tonic-gateif [ ! -f ${LPSET} -o ! -f ${LPGET} ] ; then 3677c478bd9Sstevel@tonic-gate exit_code=2 3687c478bd9Sstevel@tonic-gateelse 3697c478bd9Sstevel@tonic-gate if [ -n "${delete}" ] ; then 3707c478bd9Sstevel@tonic-gate if [ "${delete}" = "all" ] ; then 3717c478bd9Sstevel@tonic-gate delete_entries 3727c478bd9Sstevel@tonic-gate else 3737c478bd9Sstevel@tonic-gate ${LPSET} -n system -x ${delete} 3747c478bd9Sstevel@tonic-gate exit_code=$? 3757c478bd9Sstevel@tonic-gate delete_local 3767c478bd9Sstevel@tonic-gate fi 3777c478bd9Sstevel@tonic-gate fi 3787c478bd9Sstevel@tonic-gate 379*355b4669Sjacobs if [ -n "${printer}" -a -n "${uri}" ] ; then 380*355b4669Sjacobs ${LPSET} -n system -a "printer-uri-supported=${uri}" ${printer} 381*355b4669Sjacobs exit_code=$? 382*355b4669Sjacobs fi 383*355b4669Sjacobs if [ -n "${printer}" -a -n "${bsdaddr}" ] ; then 384*355b4669Sjacobs ${LPSET} -n system -a "bsdaddr=${bsdaddr}" ${printer} 3857c478bd9Sstevel@tonic-gate exit_code=$? 3867c478bd9Sstevel@tonic-gate fi 3877c478bd9Sstevel@tonic-gate if [ -n "${printer}" -a -n "${description}" ] ; then 3887c478bd9Sstevel@tonic-gate ${LPSET} -n system -a "description=${description}" ${printer} 3897c478bd9Sstevel@tonic-gate exit_code=$? 3907c478bd9Sstevel@tonic-gate fi 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate# Add class for local printers only 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate if [ -n "${class}" -a -n "${printer}" \ 3957c478bd9Sstevel@tonic-gate -a -f /etc/lp/printers/${printer}/configuration ] ; then 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate ${LPGET} "${class}" > /dev/null 2>&1 3987c478bd9Sstevel@tonic-gate lpget_class=$? 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate# If the class doesn't already exist in printers.conf, add it. 4017c478bd9Sstevel@tonic-gate 402*355b4669Sjacobs server=${server:-$HOST} 403*355b4669Sjacobs uri="lpd://${server}/printers/${class}#Solaris" 404*355b4669Sjacobs bsdaddr="${server},${class},Solaris" 4057c478bd9Sstevel@tonic-gate if [ ${lpget_class} -ne 0 ] ; then 4067c478bd9Sstevel@tonic-gate ${LPSET} -n system \ 407*355b4669Sjacobs -a "printer-uri-supported=${uri}" \ 408*355b4669Sjacobs -a "bsdaddr=${bsdaddr}" \ 409*355b4669Sjacobs ${class} 4107c478bd9Sstevel@tonic-gate exit_code=$? 4117c478bd9Sstevel@tonic-gate fi 4127c478bd9Sstevel@tonic-gate fi 4137c478bd9Sstevel@tonic-gatefi 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate# /usr/lib/lp/local/lpadmin has changed the database. This cleans up cruft in the 4167c478bd9Sstevel@tonic-gate# /etc/printers.conf file that refers to deleted objects. 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate if [ -n "${pconflocalclean}" ] ; then 4197c478bd9Sstevel@tonic-gate delete_local 4207c478bd9Sstevel@tonic-gate fi 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gateexit $exit_code 423