xref: /titanic_41/usr/src/cmd/initpkg/rc2.sh (revision d58fda4376e4bf67072ce2e69f6f47036f9dbb68)
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, 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# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
25# All rights reserved.
26#
27#
28# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
29# Use is subject to license terms.
30#
31# ident	"%Z%%M%	%I%	%E% SMI"
32
33# Run Commands executed when the system is changing to init state 2,
34# traditionally called "multi-user". Pick up start-up packages for mounts,
35# daemons, services, etc.
36
37PATH=/usr/sbin:/usr/bin
38
39if [ -z "$SMF_RESTARTER" ]; then
40	echo "Cannot be run outside smf(5)"
41	exit 1
42fi
43
44action=$1
45
46# Export boot parameters to rc scripts
47
48set -- `/usr/bin/who -r`
49
50_INIT_RUN_LEVEL="$7"	# Current run-level
51_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
52_INIT_PREV_LEVEL="$9"	# Previous run-level
53
54set -- `/usr/bin/uname -a`
55
56_INIT_UTS_SYSNAME="$1"	# Operating system name (uname -s)
57_INIT_UTS_NODENAME="$2"	# Node name (uname -n)
58_INIT_UTS_RELEASE="$3"	# Operating system release (uname -r)
59_INIT_UTS_VERSION="$4"	# Operating system version (uname -v)
60_INIT_UTS_MACHINE="$5"	# Machine class (uname -m)
61_INIT_UTS_ISA="$6"	# Instruction set architecture (uname -p)
62_INIT_UTS_PLATFORM="$7"	# Platform string (uname -i)
63
64export _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
65    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
66    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
67
68_INIT_ZONENAME=`/sbin/zonename`
69
70export _INIT_ZONENAME
71
72if [ "$_INIT_ZONENAME" = "global" ]; then
73	# Export net boot configuration strategy. _INIT_NET_IF is set to the
74	# interface name of the netbooted interface if this is a net boot.
75	# _INIT_NET_STRATEGY is set to the network configuration strategy.
76	set -- `/sbin/netstrategy`
77	if [ $? -eq 0 ]; then
78		if [ "$1" = "nfs" -o "$1" = "cachefs" ]; then
79			_INIT_NET_IF="$2"
80		fi
81		_INIT_NET_STRATEGY="$3"
82		export _INIT_NET_IF _INIT_NET_STRATEGY
83	fi
84fi
85
86case $action in
87	stop)
88		if [ -d /etc/rc2.d ]; then
89			for f in /etc/rc2.d/K*; do
90				if [ ! -s $f ]; then
91					continue
92				fi
93
94				case $f in
95					*.sh)	/lib/svc/bin/lsvcrun -s $f \
96							stop ;;
97					*)	/lib/svc/bin/lsvcrun $f stop ;;
98				esac
99			done
100		fi
101		;;
102
103	start)
104		for f in /etc/rc2.d/S*; do
105			if [ -s $f ]; then
106				case $f in
107					*.sh)	/lib/svc/bin/lsvcrun -s $f \
108							start ;;
109					*)	/lib/svc/bin/lsvcrun $f start ;;
110				esac
111			fi
112		done
113		;;
114
115	*)
116		echo "Invalid argument"
117		exit 1
118esac
119
120exit 0
121