1b51e021dSjacobs#!/bin/ksh 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 6355b4669Sjacobs# Common Development and Distribution License (the "License"). 7355b4669Sjacobs# 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*4fb0018bSSumanth Naropanth# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate# 278a2216f9Sjacobs 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 3353ac4dcaSjacobsPFEXEC=/usr/bin/pfexec 347c478bd9Sstevel@tonic-gateLPSET=/usr/bin/lpset 357c478bd9Sstevel@tonic-gateLPGET=/usr/bin/lpget 360a44ef6dSjacobsLPSTAT=/usr/bin/lpstat 37b51e021dSjacobsLPADMIN=/usr/lib/lp/local/lpadmin 3853ac4dcaSjacobsLPFILTER=/usr/sbin/lpfilter 398a2216f9SjacobsCOMM=/usr/bin/comm 40c81d47afSceasthaPPDMGR=/usr/sbin/ppdmgr 41*4fb0018bSSumanth NaropanthMKTEMP="/usr/bin/mktemp -t" 427c478bd9Sstevel@tonic-gate 43b51e021dSjacobsHOST=$(/bin/uname -n) 447c478bd9Sstevel@tonic-gateexit_code=0 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gateusage() { 477c478bd9Sstevel@tonic-gate gettext "Usage:\n" 1>&2 487c478bd9Sstevel@tonic-gate gettext " lpadmin -p (printer) (options)\n" 1>&2 497c478bd9Sstevel@tonic-gate gettext " lpadmin -x (dest)\n" 1>&2 507c478bd9Sstevel@tonic-gate gettext " lpadmin -d (dest)\n" 1>&2 517c478bd9Sstevel@tonic-gate gettext " lpadmin -S print-wheel -A alert-type [ -W minutes ]\n" 1>&2 527c478bd9Sstevel@tonic-gate gettext " [ -Q requests ]\n" 1>&2 537c478bd9Sstevel@tonic-gate gettext " lpadmin -M -f form-name [ -a [ -o filebreak ]\n" 1>&2 547c478bd9Sstevel@tonic-gate gettext " [ -t tray-number ]]\n" 1>&2 557c478bd9Sstevel@tonic-gate exit 1 567c478bd9Sstevel@tonic-gate} 577c478bd9Sstevel@tonic-gate 58b51e021dSjacobs# create a filter table for LP service 59b51e021dSjacobslp_config_filters() { 60b51e021dSjacobs if [[ ! -f /etc/lp/filter.table ]] ; then 61b51e021dSjacobs cd /etc/lp/fd ; for filter in *.fd ; do 6253ac4dcaSjacobs ${PFEXEC} ${LPFILTER} \ 63b51e021dSjacobs -f $(/usr/bin/basename $filter .fd) \ 64b51e021dSjacobs -F $filter 65b51e021dSjacobs done 66b51e021dSjacobs fi 67b51e021dSjacobs} 68b51e021dSjacobs 69b51e021dSjacobs# enable/disable LP related service(s) 70b51e021dSjacobslp_config_service() { # (enable | disable) 71b51e021dSjacobs svcadm ${1} -s svc:/application/print/server:default 72b51e021dSjacobs # svcadm ${1} -s svc:/application/print/rfc1179:default 73b51e021dSjacobs # svcadm ${1} -s svc:/application/print/ipp-listener:default 74b51e021dSjacobs} 75b51e021dSjacobs 76b51e021dSjacobs# synchronize printers.conf with LP configuration changes 77b51e021dSjacobslp_config_sync_pconf() { # (pre) (post) 788a2216f9Sjacobs ADDED=$(${COMM} -13 ${1} ${2}) 798a2216f9Sjacobs REMOVED=$(${COMM} -23 ${1} ${2}) 80b51e021dSjacobs 81b51e021dSjacobs lp_server=${server:-${HOST}} 82b51e021dSjacobs for DEST in ${ADDED} ; do 83b51e021dSjacobs lp_uri="ipp://${lp_server}/printers/${DEST}" 84b51e021dSjacobs lp_bsdaddr="${lp_server},${DEST},Solaris" 85b51e021dSjacobs ${LPSET} -n system \ 86b51e021dSjacobs -a "printer-uri-supported=${lp_uri}" \ 87b51e021dSjacobs -a "bsdaddr=${lp_bsdaddr}" \ 88b51e021dSjacobs ${DEST} 2>/dev/null 89b51e021dSjacobs done 90b51e021dSjacobs 91b51e021dSjacobs for DEST in ${REMOVED} ; do 92b51e021dSjacobs ${LPSET} -n system -x ${DEST} 2>/dev/null 93b51e021dSjacobs done 94b51e021dSjacobs} 95b51e021dSjacobs 96b51e021dSjacobs# Delete all destinations in printers.conf 97b51e021dSjacobsdelete_all() { 98b51e021dSjacobs for DEST in $(lpget -n system list | egrep -e '.+:$' | sed -e 's/://') 99b51e021dSjacobs do 100b51e021dSjacobs ${LPSET} -n system -x ${DEST} 101b51e021dSjacobs status=$? 102b51e021dSjacobs done 103b51e021dSjacobs} 104b51e021dSjacobs 105c81d47afSceastha# Call the ppdmgr utility to add a new PPD file to the system. 106c81d47afSceastha# 107c81d47afSceastha# $1 - path to PPD file 108c81d47afSceastha# $2 - label name (optional) 109c81d47afSceasthaadd_new_ppd_file() { 110c81d47afSceastha # Add new ppd file and echo full path it was actually saved to 11153ac4dcaSjacobs ppdmgrcmd="${PFEXEC} ${PPDMGR} -a ${1} -w" 112c81d47afSceastha 113*4fb0018bSSumanth Naropanth ppderrfile=$(${MKTEMP} lpadminerror.XXXXXX) 114*4fb0018bSSumanth Naropanth if [[ -z "${ppderrfile}" ]] ; then 115*4fb0018bSSumanth Naropanth gettext "lpadmin: System error; cannot create temporary file\n" 1>&2 116*4fb0018bSSumanth Naropanth exit 2 117*4fb0018bSSumanth Naropanth fi 118c81d47afSceastha ppd_file=$(${ppdmgrcmd} 2>${ppderrfile}) 119c81d47afSceastha ppdmgrrc=$? 120c81d47afSceastha if [[ -s "${ppderrfile}" ]] ; then 121c81d47afSceastha print -n "lpadmin: " 1>&2 122c81d47afSceastha cat ${ppderrfile} 1>&2 123c81d47afSceastha rm -f ${ppderrfile} >/dev/null 2>&1 124c81d47afSceastha if [[ ${ppdmgrrc} -ne 0 ]] ; then 125c81d47afSceastha exit 1 126c81d47afSceastha fi 127c81d47afSceastha fi 128c81d47afSceastha rm -f ${ppderrfile} >/dev/null 2>&1 129c81d47afSceastha} 130c81d47afSceastha 131b51e021dSjacobs# 132b51e021dSjacobs# Execution begins here 133b51e021dSjacobs# 134b51e021dSjacobs 135b51e021dSjacobs# be sure that we can run lpset and lpget 136b51e021dSjacobsif [[ ! -x ${LPSET} || ! -x ${LPGET} ]] ; then 137b51e021dSjacobs gettext "lpadmin: System error; cannot set default printer\n" 1>&2 138b51e021dSjacobs exit 2 139b51e021dSjacobsfi 140b51e021dSjacobs 141b51e021dSjacobsif [[ $# -lt 1 ]] ; then 1427c478bd9Sstevel@tonic-gate usage 1437c478bd9Sstevel@tonic-gate exit 1 1447c478bd9Sstevel@tonic-gatefi 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate# Deal with the -d option independently since getopts does not handle 1477c478bd9Sstevel@tonic-gate# options that may or may not have arguments 1487c478bd9Sstevel@tonic-gate# 149b51e021dSjacobsif [[ ${1} = "-d" ]] ; then 150b51e021dSjacobs if [[ $# -eq 1 ]] ; then # remove the "default" 151b51e021dSjacobs ${LPGET} -n system _default >/dev/null 2>&1 152b51e021dSjacobs exit_code=$? 1537c478bd9Sstevel@tonic-gate 154b51e021dSjacobs if [[ ${exit_code} -eq 0 ]] ; then 155b51e021dSjacobs ${LPSET} -n system -x _default 156b51e021dSjacobs exit_code=$? 157b51e021dSjacobs else # no default, nothing to do 158b51e021dSjacobs exit_code=0 159b51e021dSjacobs fi 160b51e021dSjacobs elif [[ $# -eq 2 ]] ; then # add/change the "default" 161b51e021dSjacobs ${LPGET} -k bsdaddr ${2} >/dev/null 2>&1 162b51e021dSjacobs exit_code=$? 163b51e021dSjacobs 164b51e021dSjacobs if [[ $exit_code -eq 0 ]] ; then 165b51e021dSjacobs ${LPSET} -n system -a "use=${2}" _default 166b51e021dSjacobs exit_code=$? 167b51e021dSjacobs else # can't set default to an unconfigured printer 168b51e021dSjacobs gettext "${2}: undefined printer\n" 1>&1 169b51e021dSjacobs fi 170b51e021dSjacobs else # invalid usage 1717c478bd9Sstevel@tonic-gate usage 1727c478bd9Sstevel@tonic-gate exit 1 1737c478bd9Sstevel@tonic-gate fi 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate exit ${exit_code} 1767c478bd9Sstevel@tonic-gatefi 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate# Strip off legal options 1797c478bd9Sstevel@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 1807c478bd9Sstevel@tonic-gatedo 1817c478bd9Sstevel@tonic-gate case $arg in 1827c478bd9Sstevel@tonic-gate D) 1837c478bd9Sstevel@tonic-gate description="${OPTARG}" 1847c478bd9Sstevel@tonic-gate ;; 185c81d47afSceastha n) 186c81d47afSceastha ppd_file="${OPTARG}" 187c81d47afSceastha ;; 1887c478bd9Sstevel@tonic-gate p) 189b51e021dSjacobs if [[ -n "${delete}" ]] ; then 1907c478bd9Sstevel@tonic-gate usage 1917c478bd9Sstevel@tonic-gate fi 1927c478bd9Sstevel@tonic-gate printer=${OPTARG} 1937c478bd9Sstevel@tonic-gate ;; 1947c478bd9Sstevel@tonic-gate s) 1957c478bd9Sstevel@tonic-gate server=${OPTARG} 1967c478bd9Sstevel@tonic-gate ;; 1977c478bd9Sstevel@tonic-gate v|U) 1987c478bd9Sstevel@tonic-gate device=${OPTARG} 199b51e021dSjacobs if [[ ! -n "${server}" ]] ; then 2005c88ba20Swendyp server=${HOST} 2015c88ba20Swendyp fi 2020a44ef6dSjacobs local="true" 2037c478bd9Sstevel@tonic-gate ;; 2047c478bd9Sstevel@tonic-gate x) 205b51e021dSjacobs if [[ -n "${printer}" || -n "${server}" || \ 206b51e021dSjacobs -n "${device}" || -n "${description}" ]] ; then 2077c478bd9Sstevel@tonic-gate usage 2087c478bd9Sstevel@tonic-gate fi 2097c478bd9Sstevel@tonic-gate delete=${OPTARG} 2107c478bd9Sstevel@tonic-gate printer=${OPTARG} 211b51e021dSjacobs if [[ ${printer} = "all" ]] ; then 2127c478bd9Sstevel@tonic-gate local="true" 2137c478bd9Sstevel@tonic-gate fi 2147c478bd9Sstevel@tonic-gate ;; 2157c478bd9Sstevel@tonic-gate S|M|A) 2167c478bd9Sstevel@tonic-gate local="true" 2177c478bd9Sstevel@tonic-gate ;; 2187c478bd9Sstevel@tonic-gate c) 2197c478bd9Sstevel@tonic-gate class=${OPTARG} 2207c478bd9Sstevel@tonic-gate local="true" 221b51e021dSjacobs if [[ ! -f ${LPGET} ]] ; then 2227c478bd9Sstevel@tonic-gate gettext "lpadmin: System error; cannot set class\n " 1>&2 2237c478bd9Sstevel@tonic-gate exit 2 2247c478bd9Sstevel@tonic-gate fi 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate ${LPGET} "${class}" > /dev/null 2>&1 2277c478bd9Sstevel@tonic-gate lpget_class=$? 228b51e021dSjacobs if [[ ${lpget_class} -eq 0 && ! -r /etc/lp/classes/"${class}" ]] ; then 2297c478bd9Sstevel@tonic-gate gettext "lpadmin: ERROR: Can't create class ${class}.\n" 1>&2 2307c478bd9Sstevel@tonic-gate gettext " TO FIX: This is an existing printer name;\n" 1>&2 2317c478bd9Sstevel@tonic-gate gettext " choose another name.\n" 1>&2 2327c478bd9Sstevel@tonic-gate exit 1 2337c478bd9Sstevel@tonic-gate fi 2347c478bd9Sstevel@tonic-gate ;; 2357c478bd9Sstevel@tonic-gate r) 2367c478bd9Sstevel@tonic-gate local="true" 2377c478bd9Sstevel@tonic-gate ;; 2387c478bd9Sstevel@tonic-gate esac 2397c478bd9Sstevel@tonic-gatedone 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate# 2427c478bd9Sstevel@tonic-gate# We don't have anything to do; let user know and bail 2437c478bd9Sstevel@tonic-gate# 244b51e021dSjacobsif [[ ! -n "${printer}" && ! -n "${delete}" && ! -n "${local}" ]] ; then 2457c478bd9Sstevel@tonic-gate gettext "lpadmin: ERROR: Nothing to do.\n" 1>&2 2467c478bd9Sstevel@tonic-gate gettext " TO FIX: You must give one of these options:\n" 1>&2 2477c478bd9Sstevel@tonic-gate gettext " -p, -d, -x -S\n" 1>&2 2487c478bd9Sstevel@tonic-gate exit 1 2497c478bd9Sstevel@tonic-gatefi 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate# 2527c478bd9Sstevel@tonic-gate# Printer does not exist 2537c478bd9Sstevel@tonic-gate# To be consistent with 2.5, assume adding local printer 2547c478bd9Sstevel@tonic-gate# 255b51e021dSjacobsif [[ ! -n "${device}" && ! -n "${server}" && ! -n "${delete}" && \ 256b51e021dSjacobs ! -n "${local}" ]] ; then 2577c478bd9Sstevel@tonic-gate ${LPGET} "${printer}" > /dev/null 2>&1 2587c478bd9Sstevel@tonic-gate lpget_stat=$? 259b51e021dSjacobs if [[ ${lpget_stat} -ne 0 ]] ; then 2607c478bd9Sstevel@tonic-gate gettext "lpadmin: ERROR: Missing -U or -v option.\n" 1>&2 2617c478bd9Sstevel@tonic-gate gettext " TO FIX: Local printers must have\n" 1>&2 2627c478bd9Sstevel@tonic-gate gettext " a port defined (-v option) or\n" 1>&2 2637c478bd9Sstevel@tonic-gate gettext " have dial-out instructions (-U option).\n" 1>&2 2647c478bd9Sstevel@tonic-gate exit 1 2657c478bd9Sstevel@tonic-gate fi 2667c478bd9Sstevel@tonic-gatefi 2677c478bd9Sstevel@tonic-gate 268355b4669Sjacobs# process the "server" value 269355b4669Sjacobs# It can be a hostname, UUCP form (server!queue), RCMD form(queue@server), 270355b4669Sjacobs# or in URI form ({scheme}://{endpoint}) 271355b4669Sjacobs# 272355b4669Sjacobscase "${server}" in 273355b4669Sjacobs *://*) # URI form 274355b4669Sjacobs uri=${server} 275b51e021dSjacobs rem_printer=$(expr "${server}" : ".*://.*/\([^/]*\)") 276b51e021dSjacobs server=$(expr "${server}" : ".*://\([^/]*\)/.*") 277355b4669Sjacobs ;; 278355b4669Sjacobs *@*) # RCMD form 279b51e021dSjacobs rem_printer=$(expr "${server}" : "\(.*\)@.*") 280b51e021dSjacobs server=$(expr "${server}" : ".*@\(.*\)") 281355b4669Sjacobs ;; 282355b4669Sjacobs *!*) # UUCP form 283b51e021dSjacobs rem_printer=$(expr "${server}" : ".*!\(.*\)") 284b51e021dSjacobs server=$(expr "${server}" : "\(.*\)!.*") 285355b4669Sjacobs ;; 286355b4669Sjacobs *) # hostname 2877c478bd9Sstevel@tonic-gate rem_printer=${printer} 288355b4669Sjacobs ;; 289355b4669Sjacobsesac 290b51e021dSjacobs 2910a44ef6dSjacobs# if there is a "device" or LP configuration, it's local 2920a44ef6dSjacobsif [[ -n "${device}" || -f /etc/lp/printers/${printer}/configuration || \ 2930a44ef6dSjacobs -f /etc/lp/classes/${printer} ]] ; then 2940a44ef6dSjacobs local="true" 2950a44ef6dSjacobsfi 296b51e021dSjacobs 297b51e021dSjacobs# Do the LP configuration for a local printer served by lpsched 2980a44ef6dSjacobsif [[ -x ${LPADMIN} && -n "${local}" ]] ; then 299b51e021dSjacobs # enumerate LP configured printers before modification 300*4fb0018bSSumanth Naropanth PRE=$(${MKTEMP} lpadmin-pre.XXXXXX) 301*4fb0018bSSumanth Naropanth if [[ -z "${PRE}" ]] ; then 302*4fb0018bSSumanth Naropanth gettext "lpadmin: System error; cannot create temporary file\n" 1>&2 303*4fb0018bSSumanth Naropanth exit 2 304*4fb0018bSSumanth Naropanth fi 305*4fb0018bSSumanth Naropanth 3068a2216f9Sjacobs (/bin/ls /etc/lp/printers 2>/dev/null ; /bin/ls /etc/lp/classes \ 3078a2216f9Sjacobs 2>/dev/null) >${PRE} 308b51e021dSjacobs 309b51e021dSjacobs # if there are no printers configured, enable LP service(s) 310c81d47afSceastha [[ ! -s "${PRE}" ]] && lp_config_service enable 311b51e021dSjacobs 312b51e021dSjacobs # add filters to LP service 313b51e021dSjacobs lp_config_filters 314b51e021dSjacobs 315c81d47afSceastha # add new ppd file to PPD file repositories 316c81d47afSceastha if [[ -n "${ppd_file}" && -x ${PPDMGR} ]] ; then 317c81d47afSceastha add_new_ppd_file "${ppd_file}" 318c81d47afSceastha fi 319c81d47afSceastha 320b51e021dSjacobs # modify LP destination(s) 32153ac4dcaSjacobs CMD="${PFEXEC} ${LPADMIN}" 322b51e021dSjacobs while [[ -n "$*" ]] ; do # to deal with multi-word arguments 323b51e021dSjacobs CMD="$CMD \"$1\"" 324c81d47afSceastha # replace the ppd_file originally specified with the -n option 325c81d47afSceastha # with the one returned from call to ppdmgr 326c81d47afSceastha if [[ "${1}" = "-n" ]] ; then 327c81d47afSceastha CMD="$CMD \"${ppd_file}\"" 328c81d47afSceastha shift 329c81d47afSceastha fi 330b51e021dSjacobs shift 331b51e021dSjacobs done 332b51e021dSjacobs case "$CMD" in 333b51e021dSjacobs *\"-D\") 334b51e021dSjacobs CMD="$CMD \"\"" 335b51e021dSjacobs ;; 336b51e021dSjacobs esac 337b51e021dSjacobs 338b51e021dSjacobs # execute the LP lpadmin command 339b51e021dSjacobs eval $CMD 340b51e021dSjacobs exit_code=$? 341b51e021dSjacobs 342b51e021dSjacobs # enumerate LP configured printers after modification 343*4fb0018bSSumanth Naropanth POST=$(${MKTEMP} lpadmin-post.XXXXXX) 344*4fb0018bSSumanth Naropanth if [[ -z "${POST}" ]] ; then 345*4fb0018bSSumanth Naropanth gettext "lpadmin: System error; cannot create temporary file\n" 1>&2 346*4fb0018bSSumanth Naropanth /bin/rm -f ${PRE} >/dev/null 2>&1 347*4fb0018bSSumanth Naropanth exit 2 348*4fb0018bSSumanth Naropanth fi 349*4fb0018bSSumanth Naropanth 3508a2216f9Sjacobs (/bin/ls /etc/lp/printers 2>/dev/null ; /bin/ls /etc/lp/classes \ 3518a2216f9Sjacobs 2>/dev/null) >${POST} 352b51e021dSjacobs 353b51e021dSjacobs # if there are no destinations, disable the service(s) 3548a2216f9Sjacobs [[ ! -s "${POST}" ]] && lp_config_service disable 355b51e021dSjacobs 356b51e021dSjacobs # sync printers.conf with LP configuration 357b51e021dSjacobs lp_config_sync_pconf "${PRE}" "${POST}" 3588a2216f9Sjacobs 3598a2216f9Sjacobs /bin/rm -f ${PRE} ${POST} 360b51e021dSjacobsfi 361b51e021dSjacobs 362b51e021dSjacobs# Do any printers.conf configuration that is required 363b51e021dSjacobsif [[ -n "${delete}" ]] ; then 364b51e021dSjacobs if [[ "${delete}" = "all" ]] ; then 365b51e021dSjacobs [[ $exit_code -eq 0 ]] && delete_all 3660a44ef6dSjacobs elif [[ -z "${local}" ]] ; then 3677c478bd9Sstevel@tonic-gate ${LPSET} -n system -x ${delete} 3687c478bd9Sstevel@tonic-gate exit_code=$? 3697c478bd9Sstevel@tonic-gate fi 370bcdabfc4SJonathan Cowper-Andreweselse 371bcdabfc4SJonathan Cowper-Andrewes if [[ -z "${local}" ]] ; then 372c74d5d46Sjacobs # if we need a uri, find the "best" one. 373c74d5d46Sjacobs if [[ -z "${uri}" ]] ; then 374c74d5d46Sjacobs uri="ipp://${server}/printers/${rem_printer}" 375c74d5d46Sjacobs ${LPSTAT} -p ${uri} >/dev/null 2>&1 376c74d5d46Sjacobs if [[ $? -ne 0 ]] ; then 377c74d5d46Sjacobs uri="lpd://${server}/printers/${rem_printer}#Solaris" 378c74d5d46Sjacobs fi 379c74d5d46Sjacobs fi 380c74d5d46Sjacobs # set the bsdaddr 381c74d5d46Sjacobs bsdaddr="${server},${rem_printer},Solaris" 382c74d5d46Sjacobs 383acecc18aSJonathan Cowper-Andrewes if [[ -n "${printer}" && -n "${server}" ]] ; then 3847c478bd9Sstevel@tonic-gate ${LPSET} -n system \ 385355b4669Sjacobs -a "printer-uri-supported=${uri}" \ 386b51e021dSjacobs -a "bsdaddr=${bsdaddr}" ${printer} 387b51e021dSjacobs exit_code=$? 388b51e021dSjacobs fi 389b51e021dSjacobs 390bcdabfc4SJonathan Cowper-Andrewes fi 391bcdabfc4SJonathan Cowper-Andrewes 392b51e021dSjacobs if [[ -n "${printer}" && -n "${description}" ]] ; then 393b51e021dSjacobs ${LPSET} -n system \ 394b51e021dSjacobs -a "description=${description}" ${printer} 3957c478bd9Sstevel@tonic-gate exit_code=$? 3967c478bd9Sstevel@tonic-gate fi 3977c478bd9Sstevel@tonic-gatefi 3987c478bd9Sstevel@tonic-gate 399b51e021dSjacobs# if the "default" doesn't resolve a "bsdaddr", the printer is gone, remove it 400b51e021dSjacobs${LPGET} -n system -k bsdaddr _default >/dev/null 2>&1 || 401b51e021dSjacobs ${LPSET} -n system -x _default >/dev/null 2>&1 4027c478bd9Sstevel@tonic-gate 4037c478bd9Sstevel@tonic-gateexit $exit_code 404