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