xref: /illumos-gate/usr/src/cmd/lp/cmd/lpsched/print-svc (revision e9542cf7)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
27#
28
29. /lib/svc/share/smf_include.sh
30. /lib/svc/share/ipf_include.sh
31
32# SERVICE = parent service name
33SERVICE=`echo $SMF_FMRI | /usr/bin/cut -f1,2 -d":"`
34
35case "$1" in
36'start')
37
38isopts=`/usr/sbin/svccfg <<-EOF
39	select $SMF_FMRI
40	listpg cmd_opts
41
42	EOF`
43
44if [ "$isopts" ] ; then
45
46#called by /usr/lib/lpsched; use cmd_opts properties only
47
48	num_notifiers=`/bin/svcprop -p cmd_opts/num_notifiers $SMF_FMRI`
49
50	if [ "$num_notifiers" != "" ] ; then
51		OPTS="$OPTS -n $num_notifiers" 
52	fi
53
54	num_filters=`/bin/svcprop -p cmd_opts/num_filters $SMF_FMRI`
55
56	if [ "$num_filters" != "" ]  ; then
57		OPTS="$OPTS -f $num_filters"
58	fi
59
60	fd_limit=`/bin/svcprop -p cmd_opts/fd_limit $SMF_FMRI`
61
62	if [ "$fd_limit" != "" ]  ; then
63		OPTS="$OPTS -p $fd_limit"
64	fi
65
66	reserved_fds=`/bin/svcprop -p cmd_opts/reserved_fds $SMF_FMRI`
67
68	if [ "$reserved_fds" != "" ] ; then
69		OPTS="$OPTS -r $reserved_fds"
70	fi
71
72# clear out cmd_opts property group
73
74	svccfg <<-EOF
75	select $SMF_FMRI
76	delpg cmd_opts
77
78	EOF
79
80else
81
82# We are here through enable; use lpsched properties
83# Check for saved properties
84
85	num_notifiers=`/bin/svcprop -p lpsched/num_notifiers $SERVICE`
86	if [ "$num_notifiers" != "" ] && [ "$num_notifiers" != "0" ] ; then
87		OPTS="$OPTS -n $num_notifiers"
88	fi
89
90	num_filters=`/bin/svcprop -p lpsched/num_filters $SERVICE`
91	if [ "$num_filters" != "" ] && [ "$num_filters" != "0" ] ; then
92		OPTS="$OPTS -f $num_filters"
93	fi
94
95	fd_limit=`/bin/svcprop -p lpsched/fd_limit $SERVICE`
96	if [ "$fd_limit" != "" ]  && [ "$fd_limit" != "0" ]; then
97		OPTS="$OPTS -p $fd_limit"
98	fi
99
100	reserved_fds=`/bin/svcprop -p lpsched/reserved_fds $SERVICE`
101	if [ "$reserved_fds" != "" ] && [ "$reserved_fds" != "0" ] ; then
102		OPTS="$OPTS -r $reserved_fds"
103	fi
104fi
105
106# set temporary or permanent properties from OPTS
107
108	[ -f /usr/lib/lp/local/lpsched ] || exit $SMF_EXIT_ERR_CONFIG
109
110	/usr/lib/lp/local/lpsched ${OPTS}
111
112	;;
113
114'stop')
115	[ -f /usr/lib/lp/local/lpshut ] || exit $SMF_EXIT_ERR_CONFIG
116
117	/usr/lib/lp/local/lpshut
118	;;
119
120'ipfilter')
121	FMRI=$2
122	RFC1179_FMRI="svc:/application/print/rfc1179:default"
123
124	policy=`get_policy $FMRI`
125
126	file=`fmri_to_file $RFC1179_FMRI $IPF_SUFFIX`
127	file6=`fmri_to_file $RFC1179_FMRI $IPF6_SUFFIX`
128	echo "# $RFC1179_FMRI" >$file
129	echo "# $RFC1179_FMRI" >$file6
130        service_is_enabled ${RFC1179_FMRI}
131        if [ $? -eq 0 ]; then
132		rfc_name=`svcprop -p inetd/name ${RFC1179_FMRI} 2>/dev/null`
133		rfc_proto=`svcprop -p inetd/proto ${RFC1179_FMRI} 2>/dev/null | \
134		    sed 's/6/ /'`
135		rfc_port=`$SERVINFO -p -t -s $rfc_name`
136		generate_rules $FMRI $policy $rfc_proto $rfc_port $file
137		generate_rules $FMRI $policy $rfc_proto $rfc_port $file6 _6
138        fi
139
140	;;
141
142*)
143	echo "Usage: $0 { start | stop }"
144	exit 1
145	;;
146esac
147exit $SMF_EXIT_OK
148