xref: /illumos-gate/usr/src/cmd/initpkg/rc2.sh (revision bbf21555)
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
317c478bd9Sstevel@tonic-gate# Run Commands executed when the system is changing to init state 2,
327c478bd9Sstevel@tonic-gate# traditionally called "multi-user". Pick up start-up packages for mounts,
337c478bd9Sstevel@tonic-gate# daemons, services, etc.
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
38*bbf21555SRichard Lowe	echo "Cannot be run outside smf(7)"
397c478bd9Sstevel@tonic-gate	exit 1
407c478bd9Sstevel@tonic-gatefi
417c478bd9Sstevel@tonic-gate
426927f468Sdp. /lib/svc/share/smf_include.sh
436927f468Sdp
447c478bd9Sstevel@tonic-gateaction=$1
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate# Export boot parameters to rc scripts
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gateset -- `/usr/bin/who -r`
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
517c478bd9Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
527c478bd9Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gateset -- `/usr/bin/uname -a`
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"	# Operating system name (uname -s)
577c478bd9Sstevel@tonic-gate_INIT_UTS_NODENAME="$2"	# Node name (uname -n)
587c478bd9Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"	# Operating system release (uname -r)
597c478bd9Sstevel@tonic-gate_INIT_UTS_VERSION="$4"	# Operating system version (uname -v)
607c478bd9Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"	# Machine class (uname -m)
617c478bd9Sstevel@tonic-gate_INIT_UTS_ISA="$6"	# Instruction set architecture (uname -p)
627c478bd9Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7"	# Platform string (uname -i)
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
657c478bd9Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
667c478bd9Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
677c478bd9Sstevel@tonic-gate
686927f468Sdp#
696927f468Sdp# Set _INIT_NET_STRATEGY and _INIT_NET_IF variables from /sbin/netstrategy
706927f468Sdp#
716927f468Sdpsmf_netstrategy
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gatecase $action in
747c478bd9Sstevel@tonic-gate	stop)
757c478bd9Sstevel@tonic-gate		if [ -d /etc/rc2.d ]; then
767c478bd9Sstevel@tonic-gate			for f in /etc/rc2.d/K*; do
777c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
787c478bd9Sstevel@tonic-gate					continue
797c478bd9Sstevel@tonic-gate				fi
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate				case $f in
827c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f \
837c478bd9Sstevel@tonic-gate							stop ;;
847c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f stop ;;
857c478bd9Sstevel@tonic-gate				esac
867c478bd9Sstevel@tonic-gate			done
877c478bd9Sstevel@tonic-gate		fi
887c478bd9Sstevel@tonic-gate		;;
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate	start)
917c478bd9Sstevel@tonic-gate		for f in /etc/rc2.d/S*; do
927c478bd9Sstevel@tonic-gate			if [ -s $f ]; then
937c478bd9Sstevel@tonic-gate				case $f in
947c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f \
957c478bd9Sstevel@tonic-gate							start ;;
967c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f start ;;
977c478bd9Sstevel@tonic-gate				esac
987c478bd9Sstevel@tonic-gate			fi
997c478bd9Sstevel@tonic-gate		done
1007c478bd9Sstevel@tonic-gate		;;
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate	*)
1037c478bd9Sstevel@tonic-gate		echo "Invalid argument"
1047c478bd9Sstevel@tonic-gate		exit 1
1057c478bd9Sstevel@tonic-gateesac
1067c478bd9Sstevel@tonic-gate
107facf4a8dSllaiif smf_is_globalzone; then
108facf4a8dSllai	# enable full implicit device reconfig
109facf4a8dSllai	/usr/sbin/devfsadm -S
110facf4a8dSllaifi
111facf4a8dSllai
1127c478bd9Sstevel@tonic-gateexit 0
113