lpadmin revision b51e021de072d76292addb44467f777617c6a8c1
407N/A# The contents of this file are subject to the terms of the 0N/A# Common Development and Distribution License (the "License"). 0N/A# You may not use this file except in compliance with the License. 0N/A# See the License for the specific language governing permissions 0N/A# and limitations under the License. 0N/A# When distributing Covered Code, include this CDDL HEADER in each 0N/A# If applicable, add the following below this CDDL HEADER, with the 0N/A# fields enclosed by brackets "[]" replaced with your own identifying 0N/A# information: Portions Copyright [yyyy] [name of copyright owner] 0N/A# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 0N/A# Use is subject to license terms. 4N/A# ident "%Z%%M% %I% %E% SMI" 670N/A gettext " lpadmin -S print-wheel -A alert-type [ -W minutes ]\n" 1>&2 670N/A gettext " lpadmin -M -f form-name [ -a [ -o filebreak ]\n" 1>&2 670N/A# echo names in ${1} that are not in ${2} 670N/A if [[ $i = $j ]] ; then 670N/A# create a filter table for LP service 15N/A if [[ "${1}" != "${2}" ]] ; then -a "printer-uri-supported=${lp_uri}" \ -a "bsdaddr=${lp_bsdaddr}" \ # be sure that we can run lpset and lpget gettext "lpadmin: System error; cannot set default printer\n" 1>&
2 # Deal with the -d option independently since getopts does not handle # options that may or may not have arguments if [[ ${
1} =
"-d" ]] ;
then if [[ $# -
eq 1 ]] ;
then # remove the "default" else # no default, nothing to do else # can't set default to an unconfigured printer gettext "${2}: undefined printer\n" 1>&
1 # Strip off legal options while 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 if [[ -n
"${delete}" ]] ;
then if [[ ! -n
"${server}" ]] ;
then if [[ -n
"${printer}" || -n
"${server}" || \
-n
"${device}" || -n
"${description}" ]] ;
then if [[ ! -f ${
LPGET} ]] ;
then gettext "lpadmin: System error; cannot set class\n " 1>&
2 gettext "lpadmin: ERROR: Can't create class ${class}.\n" 1>&
2 gettext " TO FIX: This is an existing printer name;\n" 1>&
2 gettext " choose another name.\n" 1>&
2 # We don't have anything to do; let user know and bail if [[ ! -n
"${printer}" && ! -n
"${delete}" && ! -n
"${local}" ]] ;
then gettext "lpadmin: ERROR: Nothing to do.\n" 1>&
2 gettext " TO FIX: You must give one of these options:\n" 1>&
2 # To be consistent with 2.5, assume adding local printer if [[ ! -n
"${device}" && ! -n
"${server}" && ! -n
"${delete}" && \
! -n
"${local}" ]] ;
then gettext "lpadmin: ERROR: Missing -U or -v option.\n" 1>&
2 gettext " TO FIX: Local printers must have\n" 1>&
2 gettext " a port defined (-v option) or\n" 1>&
2 gettext " have dial-out instructions (-U option).\n" 1>&
2 # process the "server" value # It can be a hostname, UUCP form (server!queue), RCMD form(queue@server), # or in URI form ({scheme}://{endpoint}) # default URI form is "lpd" form if [[ -n
"${server}" ]] ;
then uri=${
uri:-
"lpd://${server}/printers/${rem_printer}#Solaris"}
bsdaddr=
"${server},${rem_printer},Solaris" # Do the LP configuration for a local printer served by lpsched if [[ -x ${
LPADMIN} &&
( -n "${local}" || -n "${device}" || \ # enumerate LP configured printers before modification # if there are no printers configured, enable LP service(s) # add filters to LP service # modify LP destination(s) while [[ -n
"$*" ]] ;
do # to deal with multi-word arguments # execute the LP lpadmin command # enumerate LP configured printers after modification # if there are no destinations, disable the service(s) if [[ -n
"${delete}" ]] ;
then if [[
"${delete}" =
"all" ]] ;
then elif [[ -n
"${local}" ]] ;
then elif [[ -n
"${local}" ]] ;
then if [[ -n
"${printer}" ]] ;
then -a
"printer-uri-supported=${uri}" \
if [[ -n
"${printer}" && -n
"${description}" ]] ;
then -a
"description=${description}" ${
printer}
# if the "default" doesn't resolve a "bsdaddr", the printer is gone, remove it