xref: /illumos-gate/usr/src/cmd/initpkg/rc3.sh (revision 06ca4e396ecc93ed45a333664a51558b7e84e8f5)
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 3,
32# same as state 2 (multi-user) but with remote file sharing.
33
34PATH=/usr/sbin:/usr/bin
35
36if [ -z "$SMF_RESTARTER" ]; then
37	echo "This script cannot be run outside smf(7)."
38	exit 1
39fi
40
41. /lib/svc/share/smf_include.sh
42
43# Export boot parameters to rc scripts
44
45set -- `/usr/bin/who -r`
46
47_INIT_RUN_LEVEL="$7"	# Current run-level
48_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
49_INIT_PREV_LEVEL="$9"	# Previous run-level
50
51set -- `/usr/bin/uname -a`
52
53_INIT_UTS_SYSNAME="$1"  # Operating system name (uname -s)
54_INIT_UTS_NODENAME="$2" # Node name (uname -n)
55_INIT_UTS_RELEASE="$3"  # Operating system release (uname -r)
56_INIT_UTS_VERSION="$4"  # Operating system version (uname -v)
57_INIT_UTS_MACHINE="$5"  # Machine class (uname -m)
58_INIT_UTS_ISA="$6"      # Instruction set architecture (uname -p)
59_INIT_UTS_PLATFORM="$7" # Platform string (uname -i)
60
61export _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
62    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
63    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
64
65#
66# Set _INIT_NET_STRATEGY and _INIT_NET_IF variables from /sbin/netstrategy
67#
68smf_netstrategy
69
70
71if [ -d /etc/rc3.d ]; then
72	for f in /etc/rc3.d/K*; do
73		if [ -s $f ]; then
74			case $f in
75				*.sh)	/lib/svc/bin/lsvcrun -s $f stop ;;
76				*)	/lib/svc/bin/lsvcrun $f stop ;;
77			esac
78		fi
79	done
80
81	for f in /etc/rc3.d/S*; do
82		if [ -s $f ]; then
83			case $f in
84				*.sh)	/lib/svc/bin/lsvcrun -s $f start ;;
85				*)	/lib/svc/bin/lsvcrun $f start ;;
86			esac
87		fi
88	done
89fi
90
91if smf_is_globalzone; then
92	# Unload all the loadable modules brought in during boot
93	# Delay a few seconds to allow dtlogin to open console first.
94
95	(sleep 5; modunload -i 0) & >/dev/null 2>&1
96fi
97