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