xref: /titanic_44/usr/src/cmd/initpkg/rc3.sh (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate#!/sbin/sh
2*7c478bd9Sstevel@tonic-gate#
3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START
4*7c478bd9Sstevel@tonic-gate#
5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*7c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*7c478bd9Sstevel@tonic-gate# with the License.
9*7c478bd9Sstevel@tonic-gate#
10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
13*7c478bd9Sstevel@tonic-gate# and limitations under the License.
14*7c478bd9Sstevel@tonic-gate#
15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*7c478bd9Sstevel@tonic-gate#
21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END
22*7c478bd9Sstevel@tonic-gate#
23*7c478bd9Sstevel@tonic-gate#
24*7c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
25*7c478bd9Sstevel@tonic-gate# All rights reserved.
26*7c478bd9Sstevel@tonic-gate#
27*7c478bd9Sstevel@tonic-gate#
28*7c478bd9Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
29*7c478bd9Sstevel@tonic-gate# Use is subject to license terms.
30*7c478bd9Sstevel@tonic-gate#
31*7c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate# Run Commands executed when the system is changing to init state 3,
34*7c478bd9Sstevel@tonic-gate# same as state 2 (multi-user) but with remote file sharing.
35*7c478bd9Sstevel@tonic-gate
36*7c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
37*7c478bd9Sstevel@tonic-gate
38*7c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
39*7c478bd9Sstevel@tonic-gate	echo "This script cannot be run outside smf(5)."
40*7c478bd9Sstevel@tonic-gate	exit 1
41*7c478bd9Sstevel@tonic-gatefi
42*7c478bd9Sstevel@tonic-gate
43*7c478bd9Sstevel@tonic-gate# Export boot parameters to rc scripts
44*7c478bd9Sstevel@tonic-gate
45*7c478bd9Sstevel@tonic-gateset -- `/usr/bin/who -r`
46*7c478bd9Sstevel@tonic-gate
47*7c478bd9Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
48*7c478bd9Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
49*7c478bd9Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
50*7c478bd9Sstevel@tonic-gate
51*7c478bd9Sstevel@tonic-gateset -- `/usr/bin/uname -a`
52*7c478bd9Sstevel@tonic-gate
53*7c478bd9Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"  # Operating system name (uname -s)
54*7c478bd9Sstevel@tonic-gate_INIT_UTS_NODENAME="$2" # Node name (uname -n)
55*7c478bd9Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"  # Operating system release (uname -r)
56*7c478bd9Sstevel@tonic-gate_INIT_UTS_VERSION="$4"  # Operating system version (uname -v)
57*7c478bd9Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"  # Machine class (uname -m)
58*7c478bd9Sstevel@tonic-gate_INIT_UTS_ISA="$6"      # Instruction set architecture (uname -p)
59*7c478bd9Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7" # Platform string (uname -i)
60*7c478bd9Sstevel@tonic-gate
61*7c478bd9Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
62*7c478bd9Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
63*7c478bd9Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
64*7c478bd9Sstevel@tonic-gate
65*7c478bd9Sstevel@tonic-gate_INIT_ZONENAME=`/sbin/zonename`
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gateexport _INIT_ZONENAME
68*7c478bd9Sstevel@tonic-gate
69*7c478bd9Sstevel@tonic-gateif [ "$_INIT_ZONENAME" = "global" ]; then
70*7c478bd9Sstevel@tonic-gate	# Export net boot configuration strategy. _INIT_NET_IF is set to the
71*7c478bd9Sstevel@tonic-gate	# interface name of the netbooted interface if this is a net boot.
72*7c478bd9Sstevel@tonic-gate	# _INIT_NET_STRATEGY is set to the network configuration strategy.
73*7c478bd9Sstevel@tonic-gate	set -- `/sbin/netstrategy`
74*7c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
75*7c478bd9Sstevel@tonic-gate		if [ "$1" = "nfs" -o "$1" = "cachefs" ]; then
76*7c478bd9Sstevel@tonic-gate			_INIT_NET_IF="$2"
77*7c478bd9Sstevel@tonic-gate		fi
78*7c478bd9Sstevel@tonic-gate		_INIT_NET_STRATEGY="$3"
79*7c478bd9Sstevel@tonic-gate		export _INIT_NET_IF _INIT_NET_STRATEGY
80*7c478bd9Sstevel@tonic-gate	fi
81*7c478bd9Sstevel@tonic-gatefi
82*7c478bd9Sstevel@tonic-gate
83*7c478bd9Sstevel@tonic-gateif [ -d /etc/rc3.d ]; then
84*7c478bd9Sstevel@tonic-gate	for f in /etc/rc3.d/K*; do
85*7c478bd9Sstevel@tonic-gate		if [ -s $f ]; then
86*7c478bd9Sstevel@tonic-gate			case $f in
87*7c478bd9Sstevel@tonic-gate				*.sh)	/lib/svc/bin/lsvcrun -s $f stop ;;
88*7c478bd9Sstevel@tonic-gate				*)	/lib/svc/bin/lsvcrun $f stop ;;
89*7c478bd9Sstevel@tonic-gate			esac
90*7c478bd9Sstevel@tonic-gate		fi
91*7c478bd9Sstevel@tonic-gate	done
92*7c478bd9Sstevel@tonic-gate
93*7c478bd9Sstevel@tonic-gate	for f in /etc/rc3.d/S*; do
94*7c478bd9Sstevel@tonic-gate		if [ -s $f ]; then
95*7c478bd9Sstevel@tonic-gate			case $f in
96*7c478bd9Sstevel@tonic-gate				*.sh)	/lib/svc/bin/lsvcrun -s $f start ;;
97*7c478bd9Sstevel@tonic-gate				*)	/lib/svc/bin/lsvcrun $f start ;;
98*7c478bd9Sstevel@tonic-gate			esac
99*7c478bd9Sstevel@tonic-gate		fi
100*7c478bd9Sstevel@tonic-gate	done
101*7c478bd9Sstevel@tonic-gatefi
102*7c478bd9Sstevel@tonic-gate
103*7c478bd9Sstevel@tonic-gateif [ "$_INIT_ZONENAME" = "global" ]; then
104*7c478bd9Sstevel@tonic-gate	# Unload all the loadable modules brought in during boot
105*7c478bd9Sstevel@tonic-gate	# Delay a few seconds to allow dtlogin to open console first.
106*7c478bd9Sstevel@tonic-gate
107*7c478bd9Sstevel@tonic-gate	(sleep 5; modunload -i 0) & >/dev/null 2>&1
108*7c478bd9Sstevel@tonic-gatefi
109