lpadmin revision 0a44ef6d9afbfe052a7e975f55ea0d2954b62a82
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
TEXTDOMAIN="SUNW_OST_OSCMD"
export TEXTDOMAIN
exit 1
}
# echo names in ${1} that are not in ${2}
for i in ${1} ; do
MATCHED=0
for j in ${2} ; do
if [[ $i = $j ]] ; then
MATCHED=1
fi
done
if [[ $MATCHED == 0 ]] ; then
echo $i
fi
done
}
# create a filter table for LP service
if [[ ! -f /etc/lp/filter.table ]] ; then
-F $filter
done
fi
}
# svcadm ${1} -s svc:/application/print/rfc1179:default
# svcadm ${1} -s svc:/application/print/ipp-listener:default
}
# synchronize printers.conf with LP configuration changes
if [[ "${1}" != "${2}" ]] ; then
lp_uri="ipp://${lp_server}/printers/${DEST}"
lp_bsdaddr="${lp_server},${DEST},Solaris"
-a "printer-uri-supported=${lp_uri}" \
-a "bsdaddr=${lp_bsdaddr}" \
done
done
fi
}
# Delete all destinations in printers.conf
do
status=$?
done
}
#
# Execution begins here
#
# be sure that we can run lpset and lpget
exit 2
fi
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
#
if [[ ${1} = "-d" ]] ; then
exit_code=$?
exit_code=$?
else # no default, nothing to do
fi
exit_code=$?
exit_code=$?
else # can't set default to an unconfigured printer
fi
else # invalid usage
exit 1
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)
if [[ ! -n "${server}" ]] ; then
fi
local="true"
;;
x)
if [[ -n "${printer}" || -n "${server}" || \
-n "${device}" || -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)
local="true"
;;
esac
done
#
# We don't have anything to do; let user know and bail
#
if [[ ! -n "${printer}" && ! -n "${delete}" && ! -n "${local}" ]] ; then
exit 1
fi
#
# Printer does not exist
# To be consistent with 2.5, assume adding local printer
#
if [[ ! -n "${device}" && ! -n "${server}" && ! -n "${delete}" && \
! -n "${local}" ]] ; then
lpget_stat=$?
exit 1
fi
fi
# process the "server" value
# It can be a hostname, UUCP form (server!queue), RCMD form(queue@server),
# or in URI form ({scheme}://{endpoint})
#
case "${server}" in
*://*) # URI form
;;
*@*) # RCMD form
;;
*!*) # UUCP form
;;
*) # hostname
;;
esac
if [[ -n "${server}" ]] ; then
# if we need a uri, find the "best" one.
if [[ -z "${uri}" ]] ; then
uri="ipp://${server}/printers/${rem_printer}"
if [[ $? -ne 0 ]] ; then
uri="lpd://${server}/printers/${rem_printer}#Solaris"
fi
fi
# set the bsdaddr
bsdaddr="${server},${rem_printer},Solaris"
fi
# if there is a "device" or LP configuration, it's local
local="true"
fi
# Do the LP configuration for a local printer served by lpsched
if [[ -x ${LPADMIN} && -n "${local}" ]] ; then
# enumerate LP configured printers before modification
# if there are no printers configured, enable LP service(s)
# add filters to LP service
# modify LP destination(s)
while [[ -n "$*" ]] ; do # to deal with multi-word arguments
shift
done
*\"-D\")
;;
esac
# execute the LP lpadmin command
eval $CMD
exit_code=$?
# enumerate LP configured printers after modification
# if there are no destinations, disable the service(s)
# sync printers.conf with LP configuration
lp_config_sync_pconf "${PRE}" "${POST}"
fi
# Do any printers.conf configuration that is required
if [[ -n "${delete}" ]] ; then
if [[ "${delete}" = "all" ]] ; then
elif [[ -z "${local}" ]] ; then
exit_code=$?
fi
elif [[ -z "${local}" ]] ; then
if [[ -n "${printer}" ]] ; then
-a "printer-uri-supported=${uri}" \
-a "bsdaddr=${bsdaddr}" ${printer}
exit_code=$?
fi
if [[ -n "${printer}" && -n "${description}" ]] ; then
-a "description=${description}" ${printer}
exit_code=$?
fi
fi
# if the "default" doesn't resolve a "bsdaddr", the printer is gone, remove it
exit $exit_code