xref: /illumos-gate/usr/src/cmd/initpkg/rc2.sh (revision dd72704bd9e794056c558153663c739e2012d721)
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
31# Run Commands executed when the system is changing to init state 2,
32# traditionally called "multi-user". Pick up start-up packages for mounts,
33# daemons, services, etc.
34
35PATH=/usr/sbin:/usr/bin
36
37if [ -z "$SMF_RESTARTER" ]; then
38	echo "Cannot be run outside smf(7)"
39	exit 1
40fi
41
42. /lib/svc/share/smf_include.sh
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#
69# Set _INIT_NET_STRATEGY and _INIT_NET_IF variables from /sbin/netstrategy
70#
71smf_netstrategy
72
73case $action in
74	stop)
75		if [ -d /etc/rc2.d ]; then
76			for f in /etc/rc2.d/K*; do
77				if [ ! -s $f ]; then
78					continue
79				fi
80
81				case $f in
82					*.sh)	/lib/svc/bin/lsvcrun -s $f \
83							stop ;;
84					*)	/lib/svc/bin/lsvcrun $f stop ;;
85				esac
86			done
87		fi
88		;;
89
90	start)
91		for f in /etc/rc2.d/S*; do
92			if [ -s $f ]; then
93				case $f in
94					*.sh)	/lib/svc/bin/lsvcrun -s $f \
95							start ;;
96					*)	/lib/svc/bin/lsvcrun $f start ;;
97				esac
98			fi
99		done
100		;;
101
102	*)
103		echo "Invalid argument"
104		exit 1
105esac
106
107if smf_is_globalzone; then
108	# enable full implicit device reconfig
109	/usr/sbin/devfsadm -S
110fi
111
112exit 0
113