1*0Sstevel@tonic-gate#!/bin/sh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#
24*0Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
25*0Sstevel@tonic-gate# Use is subject to license terms.
26*0Sstevel@tonic-gate#
27*0Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate#
29*0Sstevel@tonic-gatePATH=/bin:/usr/bin:/usr/sbin export PATH
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateTEXTDOMAIN="SUNW_OST_OSCMD"
32*0Sstevel@tonic-gateexport TEXTDOMAIN
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateLPSET=/usr/bin/lpset
35*0Sstevel@tonic-gateLPGET=/usr/bin/lpget
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gateHOST=`/bin/uname -n`
38*0Sstevel@tonic-gatePID=$$
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gatecmd_name=lpadmin
41*0Sstevel@tonic-gateexit_code=0
42*0Sstevel@tonic-gate
43*0Sstevel@tonic-gateusage() {
44*0Sstevel@tonic-gate	gettext "Usage:\n" 1>&2
45*0Sstevel@tonic-gate	gettext "	lpadmin -p (printer) (options)\n" 1>&2
46*0Sstevel@tonic-gate	gettext "	lpadmin -x (dest)\n" 1>&2
47*0Sstevel@tonic-gate	gettext "	lpadmin -d (dest)\n" 1>&2
48*0Sstevel@tonic-gate	gettext "	lpadmin -S print-wheel -A alert-type [ -W minutes ]\n" 1>&2
49*0Sstevel@tonic-gate	gettext "		[ -Q requests ]\n" 1>&2
50*0Sstevel@tonic-gate	gettext "	lpadmin -M -f form-name [ -a [ -o filebreak ]\n" 1>&2
51*0Sstevel@tonic-gate	gettext "		[ -t tray-number ]]\n" 1>&2
52*0Sstevel@tonic-gate	exit 1
53*0Sstevel@tonic-gate}
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate#
56*0Sstevel@tonic-gate# Delete entries in /etc/printers.conf for local printers/classes that no longer
57*0Sstevel@tonic-gate# exist in the /etc/lp database
58*0Sstevel@tonic-gate#
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gatedelete_local() {
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate# Get printer names for each local printer
63*0Sstevel@tonic-gate# grep /etc/printers.conf for each bsdaddr for this server
64*0Sstevel@tonic-gate# get printer name from that line
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gatefor LINE in `grep bsdaddr=${HOST}, /etc/printers.conf`
67*0Sstevel@tonic-gatedo
68*0Sstevel@tonic-gate        PRINTER=`echo ${LINE} | sed -e 's/^:bsdaddr='$HOST',//' -e 's/[,:].*//'`
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gate# If there is not an entry for this printer in
71*0Sstevel@tonic-gate#       /etc/lp/printers or /etc/lp/classes
72*0Sstevel@tonic-gate# Then delete the entry for this printer in /etc/printers.conf
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gate        if [ ! -d /etc/lp/printers/${PRINTER} -a ! -f /etc/lp/classes/${PRINTER} ] ;
75*0Sstevel@tonic-gate        then
76*0Sstevel@tonic-gate                logger -p lpr.debug -t "lpadmin[${PID}]" \
77*0Sstevel@tonic-gate                         "Removing $PRINTER entry from /etc/printers.conf"
78*0Sstevel@tonic-gate                ${LPSET} -x ${PRINTER}
79*0Sstevel@tonic-gate                status=$?
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gate                if [ ${status} -ne 0 ] ; then
82*0Sstevel@tonic-gate                        gettext "Warning: error removing ${PRINTER} " 1>&2
83*0Sstevel@tonic-gate			gettext "entry from /etc/printers.conf\n" 1>&2
84*0Sstevel@tonic-gate                        logger -p lpr.debug -t "lpadmin[${PID}]" \
85*0Sstevel@tonic-gate				"Call to lpset -x $PRINTER exits with ${status}"
86*0Sstevel@tonic-gate			exit_code=1
87*0Sstevel@tonic-gate                fi
88*0Sstevel@tonic-gate        fi
89*0Sstevel@tonic-gatedone
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate#
92*0Sstevel@tonic-gate# shutdown scheduler if there are no local printers
93*0Sstevel@tonic-gate#
94*0Sstevel@tonic-gateCONFIGS=/etc/lp/printers/*/configuration
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gateprinters_configured=`echo $CONFIGS`
97*0Sstevel@tonic-gateif [ "$printers_configured" = "$CONFIGS" ]; then
98*0Sstevel@tonic-gate	svcprop -q svc:/application/print/server:default &&
99*0Sstevel@tonic-gate		svcadm disable svc:/application/print/server:default
100*0Sstevel@tonic-gatefi
101*0Sstevel@tonic-gate}
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gatedelete_entries() {
104*0Sstevel@tonic-gateif [ ! -f /etc/printers.conf ] ; then
105*0Sstevel@tonic-gate        logger -p lpr.debug -t "lpadmin[${PID}]" \
106*0Sstevel@tonic-gate		"System error: Cannot access /etc/printers.conf"
107*0Sstevel@tonic-gate        gettext "lpadmin: System error; Cannot access /etc/printers.conf\n" 1>&2
108*0Sstevel@tonic-gate        exit 1
109*0Sstevel@tonic-gatefi
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate# remove _default
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gateDEFAULTP=`${LPGET} _default | grep use | sed -e 's/[    ]*use=//'`
114*0Sstevel@tonic-gate${LPGET} -k bsdaddr ${DEFAULTP} >/dev/null 2>&1
115*0Sstevel@tonic-gatestatus=$?
116*0Sstevel@tonic-gate
117*0Sstevel@tonic-gateif [ ${status} -eq 0 ] ; then
118*0Sstevel@tonic-gate	${LPSET} -x _default
119*0Sstevel@tonic-gate	status=$?
120*0Sstevel@tonic-gate	if [ ${status} -ne 0 ] ; then
121*0Sstevel@tonic-gate		gettext "Warning: error removing _default entry from /etc/printers.conf\n" 1>&2
122*0Sstevel@tonic-gate		logger -p lpr.debug -t "lpadmin[${PID}]" \
123*0Sstevel@tonic-gate			"Call to lpset -x _default exits with ${status}"
124*0Sstevel@tonic-gate		exit_code=1
125*0Sstevel@tonic-gate	fi
126*0Sstevel@tonic-gatefi
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate# delete entries in /etc/printers.conf for printers/classes that have
129*0Sstevel@tonic-gate# been deleted
130*0Sstevel@tonic-gate
131*0Sstevel@tonic-gatedelete_local
132*0Sstevel@tonic-gate
133*0Sstevel@tonic-gate# Delete all the remote printers using bsdaddr
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gatefor LINE in `grep bsdaddr /etc/printers.conf | grep -v ${HOST}`
136*0Sstevel@tonic-gatedo
137*0Sstevel@tonic-gate        PRINTER=`echo $LINE | sed -e 's/^:bsdaddr=[^,]*,//' -e 's/[,:].*//'`
138*0Sstevel@tonic-gate        ${LPSET} -x $PRINTER
139*0Sstevel@tonic-gate	status=$?
140*0Sstevel@tonic-gate
141*0Sstevel@tonic-gate	if [ ${status} -ne 0 ] ; then
142*0Sstevel@tonic-gate		gettext "Warning: error removing ${PRINTER} entry from /etc/printers.conf\n" 1>&2
143*0Sstevel@tonic-gate		logger -p lpr.debug -t "lpadmin[${PID}]" \
144*0Sstevel@tonic-gate			"Call to lpset -x $PRINTER exits with ${status}"
145*0Sstevel@tonic-gate		exit_code=1
146*0Sstevel@tonic-gate	fi
147*0Sstevel@tonic-gatedone
148*0Sstevel@tonic-gate}
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gateif [ $# -lt 1 ] ; then
151*0Sstevel@tonic-gate	usage
152*0Sstevel@tonic-gate	exit 1
153*0Sstevel@tonic-gatefi
154*0Sstevel@tonic-gate
155*0Sstevel@tonic-gate# Deal with the -d option independently since getopts does not handle
156*0Sstevel@tonic-gate# options that may or may not have arguments
157*0Sstevel@tonic-gate#
158*0Sstevel@tonic-gatefirst=$1
159*0Sstevel@tonic-gatesecond=$2
160*0Sstevel@tonic-gatethird=$3
161*0Sstevel@tonic-gate
162*0Sstevel@tonic-gateif [ ${first} = "-d" ] ; then
163*0Sstevel@tonic-gate	# check that there are no extra arguments
164*0Sstevel@tonic-gate	if [ -n "${third}" ] ; then
165*0Sstevel@tonic-gate		usage
166*0Sstevel@tonic-gate		exit 1
167*0Sstevel@tonic-gate	fi
168*0Sstevel@tonic-gate
169*0Sstevel@tonic-gate
170*0Sstevel@tonic-gate	# be sure we have lpset and lpget
171*0Sstevel@tonic-gate	if [ ! -f ${LPSET} -o ! -f ${LPGET} ] ; then
172*0Sstevel@tonic-gate		gettext "lpadmin: System error; cannot set default printer\n" 1>&2
173*0Sstevel@tonic-gate		exit 2
174*0Sstevel@tonic-gate	fi
175*0Sstevel@tonic-gate
176*0Sstevel@tonic-gate	if [ ! -n "${second}" ] ; then
177*0Sstevel@tonic-gate		${LPGET} -n system _default >/dev/null 2>&1
178*0Sstevel@tonic-gate		exit_code=$?
179*0Sstevel@tonic-gate		if [ ${exit_code} -eq 0 ] ; then
180*0Sstevel@tonic-gate			# delete _default entry in /etc/printers.conf
181*0Sstevel@tonic-gate			${LPSET} -n system -x _default
182*0Sstevel@tonic-gate			exit_code=$?
183*0Sstevel@tonic-gate			if [ ${exit_code} -ne 0 ] ; then
184*0Sstevel@tonic-gate				gettext "lpadmin: System error while trying to delete default printer\n" 1>&2
185*0Sstevel@tonic-gate			fi
186*0Sstevel@tonic-gate		else
187*0Sstevel@tonic-gate			# there was no _default, the work is done
188*0Sstevel@tonic-gate			exit_code=0
189*0Sstevel@tonic-gate		fi
190*0Sstevel@tonic-gate	else
191*0Sstevel@tonic-gate		# add/change  _default entry in /etc/printers.conf
192*0Sstevel@tonic-gate		${LPGET} -k bsdaddr ${second} >/dev/null 2>&1
193*0Sstevel@tonic-gate		exit_code=$?
194*0Sstevel@tonic-gate		if [ $exit_code -eq 0 ] ; then
195*0Sstevel@tonic-gate			${LPSET} -n system -a use=${second} _default
196*0Sstevel@tonic-gate			exit_code=$?
197*0Sstevel@tonic-gate		else
198*0Sstevel@tonic-gate			echo "${second}: " 1>&2
199*0Sstevel@tonic-gate			gettext "undefined printer\n" 1>&2
200*0Sstevel@tonic-gate		fi
201*0Sstevel@tonic-gate
202*0Sstevel@tonic-gate	fi
203*0Sstevel@tonic-gate	exit ${exit_code}
204*0Sstevel@tonic-gatefi
205*0Sstevel@tonic-gate
206*0Sstevel@tonic-gate#		Strip off legal options
207*0Sstevel@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
208*0Sstevel@tonic-gatedo
209*0Sstevel@tonic-gate	case $arg in
210*0Sstevel@tonic-gate	D)
211*0Sstevel@tonic-gate		description="${OPTARG}"
212*0Sstevel@tonic-gate	;;
213*0Sstevel@tonic-gate	p)
214*0Sstevel@tonic-gate		if [ -n "${delete}" ] ; then
215*0Sstevel@tonic-gate			usage
216*0Sstevel@tonic-gate		fi
217*0Sstevel@tonic-gate		printer=${OPTARG}
218*0Sstevel@tonic-gate	;;
219*0Sstevel@tonic-gate	s)
220*0Sstevel@tonic-gate		server=${OPTARG}
221*0Sstevel@tonic-gate	;;
222*0Sstevel@tonic-gate	v|U)
223*0Sstevel@tonic-gate		device=${OPTARG}
224*0Sstevel@tonic-gate		server=`uname -n`
225*0Sstevel@tonic-gate	;;
226*0Sstevel@tonic-gate	x)
227*0Sstevel@tonic-gate		if [ -n "${printer}" -o -n "${server}" -o \
228*0Sstevel@tonic-gate		     -n "${device}" -o -n "${description}" ] ; then
229*0Sstevel@tonic-gate			usage
230*0Sstevel@tonic-gate		fi
231*0Sstevel@tonic-gate		delete=${OPTARG}
232*0Sstevel@tonic-gate		printer=${OPTARG}
233*0Sstevel@tonic-gate		if [ ${printer} = "all" ] ; then
234*0Sstevel@tonic-gate			local="true"
235*0Sstevel@tonic-gate		fi
236*0Sstevel@tonic-gate	;;
237*0Sstevel@tonic-gate	S|M|A)
238*0Sstevel@tonic-gate		local="true"
239*0Sstevel@tonic-gate	;;
240*0Sstevel@tonic-gate	c)
241*0Sstevel@tonic-gate		class=${OPTARG}
242*0Sstevel@tonic-gate		local="true"
243*0Sstevel@tonic-gate		if [ ! -f ${LPGET} ] ; then
244*0Sstevel@tonic-gate			gettext "lpadmin: System error; cannot set class\n " 1>&2
245*0Sstevel@tonic-gate			exit 2
246*0Sstevel@tonic-gate		fi
247*0Sstevel@tonic-gate
248*0Sstevel@tonic-gate		${LPGET} "${class}" > /dev/null 2>&1
249*0Sstevel@tonic-gate		lpget_class=$?
250*0Sstevel@tonic-gate		if [ ${lpget_class} -eq 0 -a ! -r /etc/lp/classes/"${class}" ] ; then
251*0Sstevel@tonic-gate			gettext "lpadmin: ERROR: Can't create class ${class}.\n" 1>&2
252*0Sstevel@tonic-gate			gettext "           TO FIX: This is an existing printer name;\n" 1>&2
253*0Sstevel@tonic-gate			gettext "                   choose another name.\n" 1>&2
254*0Sstevel@tonic-gate			exit 1
255*0Sstevel@tonic-gate		fi
256*0Sstevel@tonic-gate	;;
257*0Sstevel@tonic-gate	r)
258*0Sstevel@tonic-gate		pconflocalclean="true"
259*0Sstevel@tonic-gate		local="true"
260*0Sstevel@tonic-gate	;;
261*0Sstevel@tonic-gate	esac
262*0Sstevel@tonic-gatedone
263*0Sstevel@tonic-gate
264*0Sstevel@tonic-gate#
265*0Sstevel@tonic-gate# We don't have anything to do; let user know and bail
266*0Sstevel@tonic-gate#
267*0Sstevel@tonic-gateif [ ! -n "${printer}" -a ! -n "${delete}" -a ! -n "${local}" ] ; then
268*0Sstevel@tonic-gate	gettext "lpadmin: ERROR: Nothing to do.\n" 1>&2
269*0Sstevel@tonic-gate	gettext "        TO FIX: You must give one of these options:\n" 1>&2
270*0Sstevel@tonic-gate	gettext "		      -p, -d, -x -S\n" 1>&2
271*0Sstevel@tonic-gate	exit 1
272*0Sstevel@tonic-gatefi
273*0Sstevel@tonic-gate
274*0Sstevel@tonic-gate#
275*0Sstevel@tonic-gate#       Printer does not exist
276*0Sstevel@tonic-gate#       To be consistent with 2.5, assume adding local printer
277*0Sstevel@tonic-gate#
278*0Sstevel@tonic-gateif [ ! -n "${device}" -a ! -n "${server}" -a ! -n "${delete}" \
279*0Sstevel@tonic-gate					 -a ! -n "${local}" ] ; then
280*0Sstevel@tonic-gate	${LPGET} "${printer}" > /dev/null 2>&1
281*0Sstevel@tonic-gate	lpget_stat=$?
282*0Sstevel@tonic-gate	if [ ${lpget_stat} -ne 0 ] ; then
283*0Sstevel@tonic-gate		gettext "lpadmin: ERROR: Missing -U or -v option.\n" 1>&2
284*0Sstevel@tonic-gate		gettext "           TO FIX: Local printers must have\n" 1>&2
285*0Sstevel@tonic-gate		gettext "                   a port defined (-v option) or\n" 1>&2
286*0Sstevel@tonic-gate		gettext "                   have dial-out instructions (-U option).\n" 1>&2
287*0Sstevel@tonic-gate		exit 1
288*0Sstevel@tonic-gate	fi
289*0Sstevel@tonic-gatefi
290*0Sstevel@tonic-gate
291*0Sstevel@tonic-gate#
292*0Sstevel@tonic-gate#	Do the LP configuration for a local printer served by lpsched
293*0Sstevel@tonic-gate#
294*0Sstevel@tonic-gateif [ -f /usr/lib/lp/local/$cmd_name ] ; then
295*0Sstevel@tonic-gate	if [ -f /etc/lp/printers/${printer}/configuration -o -n "${device}" -o \
296*0Sstevel@tonic-gate	     -f /etc/lp/classes/${printer} -o -n "${local}" ] ; then
297*0Sstevel@tonic-gate		# to deal with multi-word arguments
298*0Sstevel@tonic-gate		CMD="/usr/lib/lp/local/$cmd_name"
299*0Sstevel@tonic-gate		while [ -n "$*" ] ; do
300*0Sstevel@tonic-gate			CMD="$CMD \"$1\""
301*0Sstevel@tonic-gate			shift
302*0Sstevel@tonic-gate		done
303*0Sstevel@tonic-gate		case "$CMD" in
304*0Sstevel@tonic-gate			*\"-D\")
305*0Sstevel@tonic-gate				CMD="$CMD \"\""
306*0Sstevel@tonic-gate			;;
307*0Sstevel@tonic-gate		esac
308*0Sstevel@tonic-gate		# if adding a printer, make sure scheduler is running
309*0Sstevel@tonic-gate		if [ -n "${printer}" -a ! -n "${delete}" -a \
310*0Sstevel@tonic-gate		    ! -p /var/spool/lp/fifos/FIFO ]; then
311*0Sstevel@tonic-gate			svcadm enable svc:/application/print/server:default
312*0Sstevel@tonic-gate		fi
313*0Sstevel@tonic-gate		eval $CMD
314*0Sstevel@tonic-gate		exit_code=$?
315*0Sstevel@tonic-gate	fi
316*0Sstevel@tonic-gatefi
317*0Sstevel@tonic-gate
318*0Sstevel@tonic-gateif [ $exit_code != 0 ] ; then
319*0Sstevel@tonic-gate	exit $exit_code
320*0Sstevel@tonic-gatefi
321*0Sstevel@tonic-gate
322*0Sstevel@tonic-gate
323*0Sstevel@tonic-gate#	split the "server" into printer and server
324*0Sstevel@tonic-gateif [ -n "${server}" ] ; then
325*0Sstevel@tonic-gate	if [ `echo ${server} | grep -c !` = 1 ] ; then
326*0Sstevel@tonic-gate		rem_printer=`echo ${server} | cut -d! -f2`
327*0Sstevel@tonic-gate	fi
328*0Sstevel@tonic-gate	server=`echo ${server} | cut -d! -f1`
329*0Sstevel@tonic-gatefi
330*0Sstevel@tonic-gate
331*0Sstevel@tonic-gateif [ -z "${rem_printer}" ] ; then
332*0Sstevel@tonic-gate	rem_printer=${printer}
333*0Sstevel@tonic-gatefi
334*0Sstevel@tonic-gate
335*0Sstevel@tonic-gate
336*0Sstevel@tonic-gate
337*0Sstevel@tonic-gate#
338*0Sstevel@tonic-gate#	Do the Solstice Print Configuration in /etc
339*0Sstevel@tonic-gate#
340*0Sstevel@tonic-gateif [ ! -f ${LPSET} -o ! -f ${LPGET} ] ; then
341*0Sstevel@tonic-gate	exit_code=2
342*0Sstevel@tonic-gateelse
343*0Sstevel@tonic-gate	if [ -n "${delete}" ] ; then
344*0Sstevel@tonic-gate		if [ "${delete}" = "all" ] ; then
345*0Sstevel@tonic-gate			delete_entries
346*0Sstevel@tonic-gate   		else
347*0Sstevel@tonic-gate   			${LPSET} -n system -x ${delete}
348*0Sstevel@tonic-gate   			exit_code=$?
349*0Sstevel@tonic-gate			delete_local
350*0Sstevel@tonic-gate   		fi
351*0Sstevel@tonic-gate	fi
352*0Sstevel@tonic-gate
353*0Sstevel@tonic-gate	if [ -n "${printer}" -a -n "${server}" ] ; then
354*0Sstevel@tonic-gate		${LPSET} -n system \
355*0Sstevel@tonic-gate			-a "bsdaddr=${server},${rem_printer},Solaris" \
356*0Sstevel@tonic-gate			${printer}
357*0Sstevel@tonic-gate		exit_code=$?
358*0Sstevel@tonic-gate	fi
359*0Sstevel@tonic-gate	if [ -n "${printer}" -a -n "${description}" ] ; then
360*0Sstevel@tonic-gate		${LPSET} -n system -a "description=${description}" ${printer}
361*0Sstevel@tonic-gate		exit_code=$?
362*0Sstevel@tonic-gate	fi
363*0Sstevel@tonic-gate
364*0Sstevel@tonic-gate#	Add class for local printers only
365*0Sstevel@tonic-gate
366*0Sstevel@tonic-gate	if [ -n "${class}" -a -n "${printer}" \
367*0Sstevel@tonic-gate		-a -f /etc/lp/printers/${printer}/configuration ] ; then
368*0Sstevel@tonic-gate
369*0Sstevel@tonic-gate		${LPGET} "${class}" > /dev/null 2>&1
370*0Sstevel@tonic-gate		lpget_class=$?
371*0Sstevel@tonic-gate
372*0Sstevel@tonic-gate#		If the class doesn't already exist in printers.conf, add it.
373*0Sstevel@tonic-gate
374*0Sstevel@tonic-gate		if [ ${lpget_class} -ne 0 ] ; then
375*0Sstevel@tonic-gate			this_server=`uname -n`
376*0Sstevel@tonic-gate			${LPSET} -n system \
377*0Sstevel@tonic-gate				-a "bsdaddr=${this_server},${class},Solaris" ${class}
378*0Sstevel@tonic-gate			exit_code=$?
379*0Sstevel@tonic-gate		fi
380*0Sstevel@tonic-gate	fi
381*0Sstevel@tonic-gatefi
382*0Sstevel@tonic-gate
383*0Sstevel@tonic-gate# /usr/lib/lp/local/lpadmin has changed the database. This cleans up cruft in the
384*0Sstevel@tonic-gate# /etc/printers.conf file that refers to deleted objects.
385*0Sstevel@tonic-gate
386*0Sstevel@tonic-gate	if [ -n "${pconflocalclean}" ] ; then
387*0Sstevel@tonic-gate		delete_local
388*0Sstevel@tonic-gate	fi
389*0Sstevel@tonic-gate
390*0Sstevel@tonic-gateexit $exit_code
391