xref: /onnv-gate/usr/src/cmd/lp/cmd/lpsched/print-svc (revision 8823:000507e9108d)
10Sstevel@tonic-gate#!/sbin/sh
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
62589Shshaw# Common Development and Distribution License (the "License").
72589Shshaw# 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#
220Sstevel@tonic-gate#
23*8823STruong.Q.Nguyen@Sun.COM# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate# Use is subject to license terms.
250Sstevel@tonic-gate#
260Sstevel@tonic-gate#
270Sstevel@tonic-gate
280Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
29*8823STruong.Q.Nguyen@Sun.COM. /lib/svc/share/ipf_include.sh
300Sstevel@tonic-gate
312589Shshaw# SERVICE = parent service name
323125SjacobsSERVICE=`echo $SMF_FMRI | /usr/bin/cut -f1,2 -d":"`
330Sstevel@tonic-gate
340Sstevel@tonic-gatecase "$1" in
350Sstevel@tonic-gate'start')
360Sstevel@tonic-gate
370Sstevel@tonic-gateisopts=`/usr/sbin/svccfg <<-EOF
382589Shshaw	select $SMF_FMRI
390Sstevel@tonic-gate	listpg cmd_opts
400Sstevel@tonic-gate
410Sstevel@tonic-gate	EOF`
420Sstevel@tonic-gate
430Sstevel@tonic-gateif [ "$isopts" ] ; then
440Sstevel@tonic-gate
450Sstevel@tonic-gate#called by /usr/lib/lpsched; use cmd_opts properties only
460Sstevel@tonic-gate
472589Shshaw	num_notifiers=`/bin/svcprop -p cmd_opts/num_notifiers $SMF_FMRI`
480Sstevel@tonic-gate
490Sstevel@tonic-gate	if [ "$num_notifiers" != "" ] ; then
500Sstevel@tonic-gate		OPTS="$OPTS -n $num_notifiers" 
510Sstevel@tonic-gate	fi
520Sstevel@tonic-gate
532589Shshaw	num_filters=`/bin/svcprop -p cmd_opts/num_filters $SMF_FMRI`
540Sstevel@tonic-gate
550Sstevel@tonic-gate	if [ "$num_filters" != "" ]  ; then
560Sstevel@tonic-gate		OPTS="$OPTS -f $num_filters"
570Sstevel@tonic-gate	fi
580Sstevel@tonic-gate
592589Shshaw	fd_limit=`/bin/svcprop -p cmd_opts/fd_limit $SMF_FMRI`
600Sstevel@tonic-gate
610Sstevel@tonic-gate	if [ "$fd_limit" != "" ]  ; then
620Sstevel@tonic-gate		OPTS="$OPTS -p $fd_limit"
630Sstevel@tonic-gate	fi
640Sstevel@tonic-gate
652589Shshaw	reserved_fds=`/bin/svcprop -p cmd_opts/reserved_fds $SMF_FMRI`
660Sstevel@tonic-gate
670Sstevel@tonic-gate	if [ "$reserved_fds" != "" ] ; then
680Sstevel@tonic-gate		OPTS="$OPTS -r $reserved_fds"
690Sstevel@tonic-gate	fi
700Sstevel@tonic-gate
710Sstevel@tonic-gate# clear out cmd_opts property group
720Sstevel@tonic-gate
730Sstevel@tonic-gate	svccfg <<-EOF
742589Shshaw	select $SMF_FMRI
750Sstevel@tonic-gate	delpg cmd_opts
760Sstevel@tonic-gate
770Sstevel@tonic-gate	EOF
780Sstevel@tonic-gate
790Sstevel@tonic-gateelse
800Sstevel@tonic-gate
810Sstevel@tonic-gate# We are here through enable; use lpsched properties
820Sstevel@tonic-gate# Check for saved properties
830Sstevel@tonic-gate
842589Shshaw	num_notifiers=`/bin/svcprop -p lpsched/num_notifiers $SERVICE`
850Sstevel@tonic-gate	if [ "$num_notifiers" != "" ] && [ "$num_notifiers" != "0" ] ; then
860Sstevel@tonic-gate		OPTS="$OPTS -n $num_notifiers"
870Sstevel@tonic-gate	fi
880Sstevel@tonic-gate
892589Shshaw	num_filters=`/bin/svcprop -p lpsched/num_filters $SERVICE`
900Sstevel@tonic-gate	if [ "$num_filters" != "" ] && [ "$num_filters" != "0" ] ; then
910Sstevel@tonic-gate		OPTS="$OPTS -f $num_filters"
920Sstevel@tonic-gate	fi
930Sstevel@tonic-gate
942589Shshaw	fd_limit=`/bin/svcprop -p lpsched/fd_limit $SERVICE`
950Sstevel@tonic-gate	if [ "$fd_limit" != "" ]  && [ "$fd_limit" != "0" ]; then
960Sstevel@tonic-gate		OPTS="$OPTS -p $fd_limit"
970Sstevel@tonic-gate	fi
980Sstevel@tonic-gate
992589Shshaw	reserved_fds=`/bin/svcprop -p lpsched/reserved_fds $SERVICE`
1000Sstevel@tonic-gate	if [ "$reserved_fds" != "" ] && [ "$reserved_fds" != "0" ] ; then
1010Sstevel@tonic-gate		OPTS="$OPTS -r $reserved_fds"
1020Sstevel@tonic-gate	fi
1030Sstevel@tonic-gatefi
1040Sstevel@tonic-gate
1050Sstevel@tonic-gate# set temporary or permanent properties from OPTS
1060Sstevel@tonic-gate
1070Sstevel@tonic-gate	[ -f /usr/lib/lp/local/lpsched ] || exit $SMF_EXIT_ERR_CONFIG
1080Sstevel@tonic-gate
1090Sstevel@tonic-gate	/usr/lib/lp/local/lpsched ${OPTS}
1100Sstevel@tonic-gate
1110Sstevel@tonic-gate	;;
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate'stop')
1140Sstevel@tonic-gate	[ -f /usr/lib/lp/local/lpshut ] || exit $SMF_EXIT_ERR_CONFIG
1150Sstevel@tonic-gate
1160Sstevel@tonic-gate	/usr/lib/lp/local/lpshut
1170Sstevel@tonic-gate	;;
1180Sstevel@tonic-gate
119*8823STruong.Q.Nguyen@Sun.COM'ipfilter')
120*8823STruong.Q.Nguyen@Sun.COM	FMRI=$2
121*8823STruong.Q.Nguyen@Sun.COM	IPP_FMRI="svc:/application/print/ipp-listener:default"
122*8823STruong.Q.Nguyen@Sun.COM	RFC1179_FMRI="svc:/application/print/rfc1179:default"
123*8823STruong.Q.Nguyen@Sun.COM	IPP_CONF=/etc/apache/httpd-standalone-ipp.conf
124*8823STruong.Q.Nguyen@Sun.COM	ip="any"
125*8823STruong.Q.Nguyen@Sun.COM
126*8823STruong.Q.Nguyen@Sun.COM	policy=`get_policy $FMRI`
127*8823STruong.Q.Nguyen@Sun.COM
128*8823STruong.Q.Nguyen@Sun.COM	file=`fmri_to_file $RFC1179_FMRI $IPF_SUFFIX`
129*8823STruong.Q.Nguyen@Sun.COM	echo "# $RFC1179_FMRI" >$file
130*8823STruong.Q.Nguyen@Sun.COM        service_is_enabled ${RFC1179_FMRI}
131*8823STruong.Q.Nguyen@Sun.COM        if [ $? -eq 0 ]; then
132*8823STruong.Q.Nguyen@Sun.COM		rfc_name=`svcprop -p inetd/name ${RFC1179_FMRI} 2>/dev/null`
133*8823STruong.Q.Nguyen@Sun.COM		rfc_proto=`svcprop -p inetd/proto ${RFC1179_FMRI} 2>/dev/null | \
134*8823STruong.Q.Nguyen@Sun.COM		    sed 's/6/ /'`
135*8823STruong.Q.Nguyen@Sun.COM		rfc_port=`$SERVINFO -p -t -s $rfc_name`
136*8823STruong.Q.Nguyen@Sun.COM		generate_rules $FMRI $policy $rfc_proto $ip $rfc_port $file
137*8823STruong.Q.Nguyen@Sun.COM        fi
138*8823STruong.Q.Nguyen@Sun.COM
139*8823STruong.Q.Nguyen@Sun.COM	file=`fmri_to_file $IPP_FMRI $IPF_SUFFIX`
140*8823STruong.Q.Nguyen@Sun.COM	echo "# $IPP_FMRI" >$file
141*8823STruong.Q.Nguyen@Sun.COM        service_is_enabled ${IPP_FMRI}
142*8823STruong.Q.Nguyen@Sun.COM        if [ $? -eq 0 ]; then
143*8823STruong.Q.Nguyen@Sun.COM		#
144*8823STruong.Q.Nguyen@Sun.COM		# If Listen directives are used, it's possibie to listen on
145*8823STruong.Q.Nguyen@Sun.COM		# more than one ports. Process the Port directives only when Listen
146*8823STruong.Q.Nguyen@Sun.COM		# directives don't exist.
147*8823STruong.Q.Nguyen@Sun.COM		#
148*8823STruong.Q.Nguyen@Sun.COM		ipp_ports=`grep '^[ \t]*[^# ]*Listen' ${IPP_CONF} | awk '{print $2}'`
149*8823STruong.Q.Nguyen@Sun.COM
150*8823STruong.Q.Nguyen@Sun.COM		if [ -z "$ipp_ports" ]; then
151*8823STruong.Q.Nguyen@Sun.COM			ipp_ports=`grep '^[ \t]*[^# ]*Port' ${IPP_CONF} | \
152*8823STruong.Q.Nguyen@Sun.COM			    awk '{print $2}' | tail -1`
153*8823STruong.Q.Nguyen@Sun.COM		fi
154*8823STruong.Q.Nguyen@Sun.COM
155*8823STruong.Q.Nguyen@Sun.COM		for port in $ipp_ports; do
156*8823STruong.Q.Nguyen@Sun.COM			generate_rules $FMRI $policy "tcp" $ip $port $file
157*8823STruong.Q.Nguyen@Sun.COM		done
158*8823STruong.Q.Nguyen@Sun.COM	fi
159*8823STruong.Q.Nguyen@Sun.COM
160*8823STruong.Q.Nguyen@Sun.COM	;;
161*8823STruong.Q.Nguyen@Sun.COM
1620Sstevel@tonic-gate*)
1630Sstevel@tonic-gate	echo "Usage: $0 { start | stop }"
1640Sstevel@tonic-gate	exit 1
1650Sstevel@tonic-gate	;;
1660Sstevel@tonic-gateesac
1670Sstevel@tonic-gateexit $SMF_EXIT_OK
168