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# 27*3781Sceastha 28*3781Sceastha# 29*3781Sceastha# Get the make/model/nickname as well as the repository/label from ppdfilename 300Sstevel@tonic-gate# 310Sstevel@tonic-gate 32*3781Sceastha# Input 33*3781Sceastha# ppdfilename 34*3781Sceastha# /var/lp/ppd/user/HP/foo.ppd.gz 35*3781Sceastha# Output 36*3781Sceastha# make 37*3781Sceastha# model 38*3781Sceastha# label(repository letter): driver 390Sstevel@tonic-gate# 40*3781Sceastha# Lexmark 41*3781Sceastha# IBM Page Printer 3112 42*3781Sceastha# foomatic(L): Foomatic/hpijs 430Sstevel@tonic-gate# 440Sstevel@tonic-gate 450Sstevel@tonic-gateif [[ $# -lt 1 ]]; then 460Sstevel@tonic-gate exit 1 470Sstevel@tonic-gatefi 480Sstevel@tonic-gate 49*3781Sceasthacachefile=/var/lp/ppd/ppdcache 50*3781Sceastha[[ -f $cachefile ]] || exit 1 510Sstevel@tonic-gate 52*3781Sceasthacacheentry=$(/bin/grep "$1" $cachefile) 53*3781Sceastha[[ -n "$cacheentry" ]] || exit 1 540Sstevel@tonic-gate 55*3781Sceastha# 56*3781Sceastha# Retrieve the manufacturer (make) 57*3781Sceastha# Use only the first word in manufacturer entry 58*3781Sceastha# 59*3781Sceasthamanuf=$(echo "$cacheentry" | 60*3781Sceasthanawk '{FS=":"; print $1}' | 61*3781Sceasthanawk '{print $1}') 620Sstevel@tonic-gate 63*3781Sceastha# Retrieve the model 64*3781Sceasthamodel=$(echo "$cacheentry" | nawk '{FS=":"; print $2}') 650Sstevel@tonic-gate 66*3781Sceastha# Retrieve the driver 67*3781Sceasthadriver=$(echo "$cacheentry" | nawk '{FS=":"; print $3}') 680Sstevel@tonic-gate 69*3781Sceastha# 70*3781Sceastha# Retrieve the PPD path. Parse the PPD path to get the 71*3781Sceastha# label path and to figure out the repository letter 72*3781Sceastha# associated with the label path. Note: 73*3781Sceastha# the PPD file name is the 6th colon separated entry 74*3781Sceastha# in the cache entry. This is may need to be modified if the 75*3781Sceastha# format changes. 76*3781Sceastha# 77*3781Sceasthappdpath=$(echo "$cacheentry" | /bin/nawk '{FS=":"; print $6}' ) 78*3781Sceasthamanupath=$(/bin/dirname "$ppdpath") 79*3781Sceasthalabelpath=$(/bin/dirname "$manupath") 800Sstevel@tonic-gate 81*3781Sceasthacase "$labelpath" in 82*3781Sceastha/usr/share/ppd/*) 83*3781Sceastha repltr=S 84*3781Sceastha ;; 85*3781Sceastha/opt/share/ppd/*) 86*3781Sceastha repltr=V 87*3781Sceastha ;; 88*3781Sceastha/usr/local/share/ppd/*) 89*3781Sceastha repltr=A 90*3781Sceastha ;; 91*3781Sceastha/var/lp/ppd/*) 92*3781Sceastha repltr=U 93*3781Sceastha ;; 94*3781Sceasthaesac 951211Swendyp 96*3781Sceastha[[ -n "${repltr}" ]] || exit 1 97*3781Sceasthaecho "${manuf}\n${model}" 98*3781Sceasthaecho "$(/bin/basename "$labelpath")(${repltr}): $driver" 99*3781Sceastha 100*3781Sceasthaexit 0 101