xref: /titanic_51/usr/src/cmd/initpkg/rc2.sh (revision facf4a8d7b59fde89a8662b4f4c73a758e6c402c)
17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
66927f468Sdp# Common Development and Distribution License (the "License").
76927f468Sdp# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
237c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
247c478bd9Sstevel@tonic-gate# All rights reserved.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate#
276927f468Sdp# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
287c478bd9Sstevel@tonic-gate# Use is subject to license terms.
297c478bd9Sstevel@tonic-gate#
307c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate# Run Commands executed when the system is changing to init state 2,
337c478bd9Sstevel@tonic-gate# traditionally called "multi-user". Pick up start-up packages for mounts,
347c478bd9Sstevel@tonic-gate# daemons, services, etc.
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
397c478bd9Sstevel@tonic-gate	echo "Cannot be run outside smf(5)"
407c478bd9Sstevel@tonic-gate	exit 1
417c478bd9Sstevel@tonic-gatefi
427c478bd9Sstevel@tonic-gate
436927f468Sdp. /lib/svc/share/smf_include.sh
446927f468Sdp
457c478bd9Sstevel@tonic-gateaction=$1
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate# Export boot parameters to rc scripts
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gateset -- `/usr/bin/who -r`
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
527c478bd9Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
537c478bd9Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gateset -- `/usr/bin/uname -a`
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"	# Operating system name (uname -s)
587c478bd9Sstevel@tonic-gate_INIT_UTS_NODENAME="$2"	# Node name (uname -n)
597c478bd9Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"	# Operating system release (uname -r)
607c478bd9Sstevel@tonic-gate_INIT_UTS_VERSION="$4"	# Operating system version (uname -v)
617c478bd9Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"	# Machine class (uname -m)
627c478bd9Sstevel@tonic-gate_INIT_UTS_ISA="$6"	# Instruction set architecture (uname -p)
637c478bd9Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7"	# Platform string (uname -i)
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
667c478bd9Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
677c478bd9Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
687c478bd9Sstevel@tonic-gate
696927f468Sdp#
706927f468Sdp# Set _INIT_NET_STRATEGY and _INIT_NET_IF variables from /sbin/netstrategy
716927f468Sdp#
726927f468Sdpsmf_netstrategy
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gatecase $action in
757c478bd9Sstevel@tonic-gate	stop)
767c478bd9Sstevel@tonic-gate		if [ -d /etc/rc2.d ]; then
777c478bd9Sstevel@tonic-gate			for f in /etc/rc2.d/K*; do
787c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
797c478bd9Sstevel@tonic-gate					continue
807c478bd9Sstevel@tonic-gate				fi
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate				case $f in
837c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f \
847c478bd9Sstevel@tonic-gate							stop ;;
857c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f stop ;;
867c478bd9Sstevel@tonic-gate				esac
877c478bd9Sstevel@tonic-gate			done
887c478bd9Sstevel@tonic-gate		fi
897c478bd9Sstevel@tonic-gate		;;
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate	start)
927c478bd9Sstevel@tonic-gate		for f in /etc/rc2.d/S*; do
937c478bd9Sstevel@tonic-gate			if [ -s $f ]; then
947c478bd9Sstevel@tonic-gate				case $f in
957c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f \
967c478bd9Sstevel@tonic-gate							start ;;
977c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f start ;;
987c478bd9Sstevel@tonic-gate				esac
997c478bd9Sstevel@tonic-gate			fi
1007c478bd9Sstevel@tonic-gate		done
1017c478bd9Sstevel@tonic-gate		;;
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate	*)
1047c478bd9Sstevel@tonic-gate		echo "Invalid argument"
1057c478bd9Sstevel@tonic-gate		exit 1
1067c478bd9Sstevel@tonic-gateesac
1077c478bd9Sstevel@tonic-gate
108*facf4a8dSllai1if smf_is_globalzone; then
109*facf4a8dSllai1	# enable full implicit device reconfig
110*facf4a8dSllai1	/usr/sbin/devfsadm -S
111*facf4a8dSllai1fi
112*facf4a8dSllai1
1137c478bd9Sstevel@tonic-gateexit 0
114