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