8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / print / scripts / conv_lp
blob286ba6f682d5c32d96cef3569354b2a978069fdc
1 #!/bin/sh
3 # CDDL HEADER START
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
8 # with the License.
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]
21 # CDDL HEADER END
24 # Copyright (c) 1994, 1995, 1996 by Sun Microsystems, Inc.
25 # All Rights Reserved
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"
35 export TEXTDOMAIN
37 export PATH
38 umask 022
40 set -- `getopt d:f: $*`
41 if [ $? != 0 ] ; then
42 echo "Usage: $0 [-d dir] [-f file]"
43 exit 1
46 for OPTION in $*
48 case $OPTION in
49 -f) SYSTEM_FILE=$2; shift 2;;
50 -d) BASE_DIR=$2; shift 2;;
51 --) shift; break;;
52 esac
53 done
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."
59 exit 0
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
69 PRINTERS=`echo *`
71 for PRINTER in ${PRINTERS} # for each printer get config info
73 if [ "${PRINTER}" = "*" ] ; then
74 continue
77 RNAME=${PRINTER}
78 DESC=""
79 RHOST=""
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
89 RHOST=`uname -n`
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`
93 else
94 RHOST=${REMOTE}
97 lpset -n system -a "bsdaddr=${RHOST},${RNAME}" -a "description=${DESC}" \
98 ${PRINTER}
100 done
102 exit 0