xref: /titanic_50/usr/src/cmd/initpkg/rc2.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 2,
34*7c478bd9Sstevel@tonic-gate# traditionally called "multi-user". Pick up start-up packages for mounts,
35*7c478bd9Sstevel@tonic-gate# daemons, services, etc.
36*7c478bd9Sstevel@tonic-gate
37*7c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
38*7c478bd9Sstevel@tonic-gate
39*7c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
40*7c478bd9Sstevel@tonic-gate	echo "Cannot be run outside smf(5)"
41*7c478bd9Sstevel@tonic-gate	exit 1
42*7c478bd9Sstevel@tonic-gatefi
43*7c478bd9Sstevel@tonic-gate
44*7c478bd9Sstevel@tonic-gateaction=$1
45*7c478bd9Sstevel@tonic-gate
46*7c478bd9Sstevel@tonic-gate# Export boot parameters to rc scripts
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gateset -- `/usr/bin/who -r`
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
51*7c478bd9Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
52*7c478bd9Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
53*7c478bd9Sstevel@tonic-gate
54*7c478bd9Sstevel@tonic-gateset -- `/usr/bin/uname -a`
55*7c478bd9Sstevel@tonic-gate
56*7c478bd9Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"	# Operating system name (uname -s)
57*7c478bd9Sstevel@tonic-gate_INIT_UTS_NODENAME="$2"	# Node name (uname -n)
58*7c478bd9Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"	# Operating system release (uname -r)
59*7c478bd9Sstevel@tonic-gate_INIT_UTS_VERSION="$4"	# Operating system version (uname -v)
60*7c478bd9Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"	# Machine class (uname -m)
61*7c478bd9Sstevel@tonic-gate_INIT_UTS_ISA="$6"	# Instruction set architecture (uname -p)
62*7c478bd9Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7"	# Platform string (uname -i)
63*7c478bd9Sstevel@tonic-gate
64*7c478bd9Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
65*7c478bd9Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
66*7c478bd9Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
67*7c478bd9Sstevel@tonic-gate
68*7c478bd9Sstevel@tonic-gate_INIT_ZONENAME=`/sbin/zonename`
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gateexport _INIT_ZONENAME
71*7c478bd9Sstevel@tonic-gate
72*7c478bd9Sstevel@tonic-gateif [ "$_INIT_ZONENAME" = "global" ]; then
73*7c478bd9Sstevel@tonic-gate	# Export net boot configuration strategy. _INIT_NET_IF is set to the
74*7c478bd9Sstevel@tonic-gate	# interface name of the netbooted interface if this is a net boot.
75*7c478bd9Sstevel@tonic-gate	# _INIT_NET_STRATEGY is set to the network configuration strategy.
76*7c478bd9Sstevel@tonic-gate	set -- `/sbin/netstrategy`
77*7c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
78*7c478bd9Sstevel@tonic-gate		if [ "$1" = "nfs" -o "$1" = "cachefs" ]; then
79*7c478bd9Sstevel@tonic-gate			_INIT_NET_IF="$2"
80*7c478bd9Sstevel@tonic-gate		fi
81*7c478bd9Sstevel@tonic-gate		_INIT_NET_STRATEGY="$3"
82*7c478bd9Sstevel@tonic-gate		export _INIT_NET_IF _INIT_NET_STRATEGY
83*7c478bd9Sstevel@tonic-gate	fi
84*7c478bd9Sstevel@tonic-gatefi
85*7c478bd9Sstevel@tonic-gate
86*7c478bd9Sstevel@tonic-gatecase $action in
87*7c478bd9Sstevel@tonic-gate	stop)
88*7c478bd9Sstevel@tonic-gate		if [ -d /etc/rc2.d ]; then
89*7c478bd9Sstevel@tonic-gate			for f in /etc/rc2.d/K*; do
90*7c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
91*7c478bd9Sstevel@tonic-gate					continue
92*7c478bd9Sstevel@tonic-gate				fi
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gate				case $f in
95*7c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f \
96*7c478bd9Sstevel@tonic-gate							stop ;;
97*7c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f stop ;;
98*7c478bd9Sstevel@tonic-gate				esac
99*7c478bd9Sstevel@tonic-gate			done
100*7c478bd9Sstevel@tonic-gate		fi
101*7c478bd9Sstevel@tonic-gate		;;
102*7c478bd9Sstevel@tonic-gate
103*7c478bd9Sstevel@tonic-gate	start)
104*7c478bd9Sstevel@tonic-gate		for f in /etc/rc2.d/S*; do
105*7c478bd9Sstevel@tonic-gate			if [ -s $f ]; then
106*7c478bd9Sstevel@tonic-gate				case $f in
107*7c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f \
108*7c478bd9Sstevel@tonic-gate							start ;;
109*7c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f start ;;
110*7c478bd9Sstevel@tonic-gate				esac
111*7c478bd9Sstevel@tonic-gate			fi
112*7c478bd9Sstevel@tonic-gate		done
113*7c478bd9Sstevel@tonic-gate		;;
114*7c478bd9Sstevel@tonic-gate
115*7c478bd9Sstevel@tonic-gate	*)
116*7c478bd9Sstevel@tonic-gate		echo "Invalid argument"
117*7c478bd9Sstevel@tonic-gate		exit 1
118*7c478bd9Sstevel@tonic-gateesac
119*7c478bd9Sstevel@tonic-gate
120*7c478bd9Sstevel@tonic-gateexit 0
121