10Sstevel@tonic-gate#!/usr/bin/ksh 20Sstevel@tonic-gate# 30Sstevel@tonic-gate# CDDL HEADER START 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*3781Sceastha# Common Development and Distribution License (the "License"). 7*3781Sceastha# You may not use this file except in compliance with the License. 80Sstevel@tonic-gate# 90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate# See the License for the specific language governing permissions 120Sstevel@tonic-gate# and limitations under the License. 130Sstevel@tonic-gate# 140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate# 200Sstevel@tonic-gate# CDDL HEADER END 210Sstevel@tonic-gate# 22*3781Sceastha# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*3781Sceastha# Use is subject to license terms. 240Sstevel@tonic-gate# 250Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 260Sstevel@tonic-gate# 270Sstevel@tonic-gate 280Sstevel@tonic-gate# 291211Swendyp# Get the path/ppdfilename for this ppd NickName 301211Swendyp# Input: 31*3781Sceastha# make: model: ppdlabel: ppd: 32*3781Sceastha# PrintersRus: ABC Model 1234: SUNWfoomatic(S): Foomatic/Postscript (recommended): 330Sstevel@tonic-gate# 340Sstevel@tonic-gate 35*3781Sceastha# 36*3781Sceastha# Returns the full path to the repository associated with 37*3781Sceastha# the repository letter found between parenthesis in the 38*3781Sceastha# extended PPD label. 39*3781Sceastha# 40*3781Sceastha# $1 - Extended PPD label 41*3781Sceastha# 42*3781Sceastharep_path() 43*3781Sceastha{ 44*3781Sceastha case "$(expr \"$1\" : ".*(\(.*\)).*")" in 45*3781Sceastha "S") 46*3781Sceastha echo "/usr/share/ppd" 47*3781Sceastha ;; 48*3781Sceastha "V") 49*3781Sceastha echo "/opt/share/ppd" 50*3781Sceastha ;; 51*3781Sceastha "A") 52*3781Sceastha echo "/usr/local/share/ppd" 53*3781Sceastha ;; 54*3781Sceastha "U") 55*3781Sceastha echo "/var/lp/ppd" 56*3781Sceastha ;; 57*3781Sceastha esac 58*3781Sceastha} 59*3781Sceastha 60*3781Sceasthaif [[ $# -lt 4 ]]; then 610Sstevel@tonic-gate exit 1 620Sstevel@tonic-gatefi 630Sstevel@tonic-gate 64*3781Sceastha[[ -f /var/lp/ppd/ppdcache ]] || exit 1 65*3781Sceasthamake=$(echo $* | /usr/bin/nawk '{FS=":"; print $1}') 66*3781Sceastha# strip leading blanks 67*3781Sceasthamodel=$(echo $* | /usr/bin/nawk '{FS=":"; print $2}' | 68*3781Sceastha /bin/sed -e 's/^[ ]*//') 69*3781Sceasthaextppdlabel=$(echo $* | /usr/bin/nawk '{FS=":"; print $3}' | 70*3781Sceastha /bin/sed -e 's/^[ ]*//') 71*3781Sceasthappd=$(echo $* | /usr/bin/nawk '{FS=":"; print $4}' | 72*3781Sceastha /bin/sed -e 's/^[ ]*//') 730Sstevel@tonic-gate 74*3781Sceastha# 75*3781Sceastha# Do not use ":" with $make. printmgr collapses manufacturer name 76*3781Sceastha# to first word, ie PrintersRus and PrintersRus International become 77*3781Sceastha# PrintersRus. The full path to the PPD file will be the 6th 78*3781Sceastha# colon separated entry in the ppdcache entry. If the format 79*3781Sceastha# of a ppdcache entry changes, then this will need to be modified 80*3781Sceastha# also. 81*3781Sceastha# 82*3781Sceastha/bin/grep "${make}" /var/lp/ppd/ppdcache | 83*3781Sceastha /bin/grep "${model}:" | 84*3781Sceastha /bin/grep "${ppd}:" | 85*3781Sceastha /bin/grep "$(rep_path ${extppdlabel})/${extppdlabel%\(*}" | 86*3781Sceastha /usr/bin/nawk '{FS=":"; print $6}' 870Sstevel@tonic-gate 88*3781Sceasthaexit 0 89