xref: /titanic_44/usr/src/cmd/lp/cmd/scripts/lpsched (revision 99ebb4ca412cb0a19d77a3899a87c055b9c30fa8)
1#!/bin/ksh
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, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
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.
14#
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]
20#
21# CDDL HEADER END
22#
23#
24# ident	"%Z%%M%	%I%	%E% SMI"
25#
26# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29
30	[ -f /usr/lib/lp/local/lpsched ] || exit 1
31
32# Get command line options and set them in print service
33# -f num_filters
34# -n num_notifiers
35# -p fd_limit
36# -r reserved_fds
37
38# Check to see if lpsched is already running
39
40state=`svcprop -p restarter/state svc:/application/print/server:default`
41if [ "$state" = "online" ] ; then
42	/bin/gettext "Print services already active.\n"
43	exit 1
44fi
45
46OPTS=$*
47
48# no options set
49
50if [ "$OPTS" = "" ]  ; then
51	/usr/sbin/svcadm enable -t svc:/application/print/server:default
52	if [ $? = 0 ] ; then
53		/bin/gettext "Print services started.\n"
54		exit 0
55	else
56		exit 1
57	fi
58
59else
60
61# Get and set the options
62
63	/usr/sbin/svccfg <<-EOF 2>/dev/null
64		select svc:/application/print/server:default
65		addpg cmd_opts count P
66
67	EOF
68
69num_filters=0
70num_notifiers=0
71fd_limit=0
72reserved_fds=0
73
74while getopts :f:n:p:r: arg; do
75	case $arg in
76	f)
77		num_filters=$OPTARG
78
79		/usr/sbin/svccfg <<-EOF 2>/dev/null
80		select svc:/application/print/server:default
81		setprop cmd_opts/num_filters = count: ${num_filters}
82
83		EOF
84
85		;;
86
87	n)
88		num_notifiers=$OPTARG
89
90		/usr/sbin/svccfg <<-EOF 2>/dev/null
91		select svc:/application/print/server:default
92		setprop cmd_opts/num_notifiers = count:  ${num_notifiers}
93
94		EOF
95
96		;;
97
98	p)
99		fd_limit=$OPTARG
100
101		/usr/sbin/svccfg <<-EOF 2>/dev/null
102		select svc:/application/print/server:default
103		setprop cmd_opts/fd_limit = count:  ${fd_limit}
104
105		EOF
106
107		;;
108
109	r)
110		reserved_fds=$OPTARG
111
112		/usr/sbin/svccfg <<-EOF 2>/dev/null
113		select svc:/application/print/server:default
114		setprop cmd_opts/reserved_fds = count:  ${reserved_fds}
115
116		EOF
117
118		;;
119
120	*)	echo "Invalid flag -$OPTARG. Exiting"
121			exit 1
122	esac
123done
124
125	/usr/sbin/svcadm enable -t svc:/application/print/server:default
126	if [ $? = 0 ] ; then
127		/bin/gettext "Print services started.\n"
128		exit 0
129	else
130		exit 1
131	fi
132
133fi
134
135