lpadmin revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
TEXTDOMAIN="SUNW_OST_OSCMD"
export TEXTDOMAIN
PID=$$
exit 1
}
#
# Delete entries in /etc/printers.conf for local printers/classes that no longer
#
# Get printer names for each local printer
# grep /etc/printers.conf for each bsdaddr for this server
# get printer name from that line
do
# If there is not an entry for this printer in
# Then delete the entry for this printer in /etc/printers.conf
then
"Removing $PRINTER entry from /etc/printers.conf"
status=$?
"Call to lpset -x $PRINTER exits with ${status}"
fi
fi
done
#
# shutdown scheduler if there are no local printers
#
printers_configured=`echo $CONFIGS`
fi
}
if [ ! -f /etc/printers.conf ] ; then
"System error: Cannot access /etc/printers.conf"
exit 1
fi
# remove _default
status=$?
status=$?
"Call to lpset -x _default exits with ${status}"
fi
fi
# delete entries in /etc/printers.conf for printers/classes that have
# been deleted
# Delete all the remote printers using bsdaddr
do
status=$?
"Call to lpset -x $PRINTER exits with ${status}"
fi
done
}
if [ $# -lt 1 ] ; then
exit 1
fi
# Deal with the -d option independently since getopts does not handle
# options that may or may not have arguments
#
first=$1
second=$2
third=$3
if [ ${first} = "-d" ] ; then
# check that there are no extra arguments
if [ -n "${third}" ] ; then
exit 1
fi
# be sure we have lpset and lpget
exit 2
fi
if [ ! -n "${second}" ] ; then
exit_code=$?
# delete _default entry in /etc/printers.conf
exit_code=$?
fi
else
# there was no _default, the work is done
fi
else
# add/change _default entry in /etc/printers.conf
exit_code=$?
exit_code=$?
else
echo "${second}: " 1>&2
fi
fi
exit ${exit_code}
fi
# Strip off legal options
while 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
do
D)
description="${OPTARG}"
;;
p)
if [ -n "${delete}" ] ; then
fi
;;
s)
;;
v|U)
;;
x)
if [ -n "${printer}" -o -n "${server}" -o \
-n "${device}" -o -n "${description}" ] ; then
fi
if [ ${printer} = "all" ] ; then
local="true"
fi
;;
S|M|A)
local="true"
;;
c)
local="true"
if [ ! -f ${LPGET} ] ; then
exit 2
fi
lpget_class=$?
exit 1
fi
;;
r)
pconflocalclean="true"
local="true"
;;
esac
done
#
# We don't have anything to do; let user know and bail
#
if [ ! -n "${printer}" -a ! -n "${delete}" -a ! -n "${local}" ] ; then
exit 1
fi
#
# Printer does not exist
# To be consistent with 2.5, assume adding local printer
#
if [ ! -n "${device}" -a ! -n "${server}" -a ! -n "${delete}" \
-a ! -n "${local}" ] ; then
lpget_stat=$?
exit 1
fi
fi
#
# Do the LP configuration for a local printer served by lpsched
#
# to deal with multi-word arguments
while [ -n "$*" ] ; do
shift
done
*\"-D\")
;;
esac
# if adding a printer, make sure scheduler is running
if [ -n "${printer}" -a ! -n "${delete}" -a \
fi
eval $CMD
exit_code=$?
fi
fi
if [ $exit_code != 0 ] ; then
exit $exit_code
fi
# split the "server" into printer and server
if [ -n "${server}" ] ; then
rem_printer=`echo ${server} | cut -d! -f2`
fi
fi
if [ -z "${rem_printer}" ] ; then
fi
#
# Do the Solstice Print Configuration in /etc
#
else
if [ -n "${delete}" ] ; then
if [ "${delete}" = "all" ] ; then
else
exit_code=$?
fi
fi
if [ -n "${printer}" -a -n "${server}" ] ; then
-a "bsdaddr=${server},${rem_printer},Solaris" \
${printer}
exit_code=$?
fi
if [ -n "${printer}" -a -n "${description}" ] ; then
exit_code=$?
fi
# Add class for local printers only
if [ -n "${class}" -a -n "${printer}" \
lpget_class=$?
# If the class doesn't already exist in printers.conf, add it.
this_server=`uname -n`
-a "bsdaddr=${this_server},${class},Solaris" ${class}
exit_code=$?
fi
fi
fi
# /etc/printers.conf file that refers to deleted objects.
if [ -n "${pconflocalclean}" ] ; then
fi
exit $exit_code