xref: /onnv-gate/usr/src/cmd/dispadmin/svc-scheduler (revision 953:785d08a4a320)
1*953Srm88369#!/sbin/sh
2*953Srm88369#
3*953Srm88369# CDDL HEADER START
4*953Srm88369#
5*953Srm88369# The contents of this file are subject to the terms of the
6*953Srm88369# Common Development and Distribution License, Version 1.0 only
7*953Srm88369# (the "License").  You may not use this file except in compliance
8*953Srm88369# with the License.
9*953Srm88369#
10*953Srm88369# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*953Srm88369# or http://www.opensolaris.org/os/licensing.
12*953Srm88369# See the License for the specific language governing permissions
13*953Srm88369# and limitations under the License.
14*953Srm88369#
15*953Srm88369# When distributing Covered Code, include this CDDL HEADER in each
16*953Srm88369# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*953Srm88369# If applicable, add the following below this CDDL HEADER, with the
18*953Srm88369# fields enclosed by brackets "[]" replaced with your own identifying
19*953Srm88369# information: Portions Copyright [yyyy] [name of copyright owner]
20*953Srm88369#
21*953Srm88369# CDDL HEADER END
22*953Srm88369#
23*953Srm88369#
24*953Srm88369# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25*953Srm88369# Use is subject to license terms.
26*953Srm88369#
27*953Srm88369# ident	"%Z%%M%	%I%	%E% SMI"
28*953Srm88369#
29*953Srm88369# Set default scheduling class
30*953Srm88369#
31*953Srm88369
32*953Srm88369. /lib/svc/share/smf_include.sh
33*953Srm88369
34*953Srm88369[ -f /etc/dispadmin.conf ] || exit $SMF_EXIT_OK
35*953Srm88369if  [ -x /usr/sbin/dispadmin ] && [ -x /usr/bin/priocntl ]; then
36*953Srm88369	ERROR="$0: cannot set default scheduling class to "
37*953Srm88369	DISPADMIN_D=`/usr/sbin/dispadmin -d`
38*953Srm88369
39*953Srm88369	if [ $? -eq 0 ]; then
40*953Srm88369		#
41*953Srm88369		# Inform the kernel about the default scheduling class.
42*953Srm88369		#
43*953Srm88369		/usr/sbin/dispadmin -u
44*953Srm88369
45*953Srm88369		DEFAULT_SCHEDULER=`echo $DISPADMIN_D | /usr/bin/cut -f1 -d' '`
46*953Srm88369
47*953Srm88369		/usr/bin/priocntl -s -c $DEFAULT_SCHEDULER -i all
48*953Srm88369		if [ $? -ne 0 ]; then
49*953Srm88369			echo $ERROR $DEFAULT_SCHEDULER
50*953Srm88369			exit $SMF_EXIT_ERR_FATAL
51*953Srm88369		else
52*953Srm88369			#
53*953Srm88369			# Also need to move init process explicitly
54*953Srm88369			# because it was ignored by "-i all".
55*953Srm88369			#
56*953Srm88369			/usr/bin/priocntl -s -c $DEFAULT_SCHEDULER -i pid 1
57*953Srm88369			if [ $? -ne 0 ]; then
58*953Srm88369				echo $ERROR $DEFAULT_SCHEDULER
59*953Srm88369				exit $SMF_EXIT_ERR_FATAL
60*953Srm88369			fi
61*953Srm88369		fi
62*953Srm88369	else
63*953Srm88369		#
64*953Srm88369		# Default scheduling class from dispadmin.conf is
65*953Srm88369		# invalid or not available.
66*953Srm88369		#
67*953Srm88369		exit $SMF_EXIT_ERR_CONFIG
68*953Srm88369	fi
69*953Srm88369else
70*953Srm88369	# dispadmin or priocntl commands can't be executed
71*953Srm88369	echo "$0: cannot execute command"
72*953Srm88369	exit $SMF_EXIT_ERR_FATAL
73*953Srm88369fi
74*953Srm88369exit $SMF_EXIT_OK
75