5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 1994, 1995, 1996 by Sun Microsystems, Inc.
27 # ident "%Z%%M% %I% %E% SMI"
29 # This script will automatically generate a "printcap" file
30 # from the currently configured LP printer configuration.
32 PATH
=/bin
:/usr
/bin
:/usr
/sbin
34 TEXTDOMAIN
="SUNW_OST_OSCMD"
40 set -- `getopt d:f: $*`
42 echo "Usage: $0 [-d dir] [-f file]"
49 -f) SYSTEM_FILE
=$2; shift 2;;
50 -d) BASE_DIR
=$2; shift 2;;
55 SYSTEM_FILE
=${SYSTEM_FILE:-"${BASE_DIR}/etc/printers.conf"}
57 if [ ! -d ${BASE_DIR}/etc
/lp
/printers
] ; then
58 gettext "Exit $0: There is no directory ${BASE_DIR}/etc/lp/printers\n\tfrom which to create /etc/printers.conf."
62 if [ -f ${BASE_DIR}/etc
/lp
/default
] ; then
63 DEFAULT_PRINTER
=`cat ${BASE_DIR}/etc/lp/default`
64 lpset
-n system
-a "use=${DEFAULT_PRINTER}" _default
65 mv ${BASE_DIR}/etc
/lp
/default
${BASE_DIR}/etc
/default.orig
68 cd ${BASE_DIR}/etc
/lp
/printers
# get the list of locally configured printers
71 for PRINTER
in ${PRINTERS} # for each printer get config info
73 if [ "${PRINTER}" = "*" ] ; then
81 if [ -f ${PRINTER}/comment
] ; then
82 DESC
=`cat ${PRINTER}/comment`
85 REMOTE
=`grep Remote: ${PRINTER}/configuration 2>/dev/null | sed -e "s/^Remote: //"`
86 DEVICE
=`grep Device: ${PRINTER}/configuration 2>/dev/null | sed -e "s/^Device: //"`
88 if [ -n "${DEVICE}" ] ; then
90 elif [ `echo ${REMOTE} | grep -c \!` -ne 0 ] ; then
91 RHOST
=`echo $REMOTE | cut -d \! -f 1`
92 RNAME
=`echo $REMOTE | cut -d \! -f 2`
97 lpset
-n system
-a "bsdaddr=${RHOST},${RNAME}" -a "description=${DESC}" \