xref: /illumos-gate/usr/src/cmd/initpkg/rc0.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
64d53c7adSDan Price# Common Development and Distribution License (the "License").
74d53c7adSDan Price# 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#
274d53c7adSDan Price# Copyright 2009 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" for init states 0, 5 and 6.
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
36*bbf21555SRichard Lowe	echo "Cannot be run outside smf(7)"
377c478bd9Sstevel@tonic-gate	exit 1
387c478bd9Sstevel@tonic-gatefi
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate# Export boot parameters to rc scripts
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gateset -- `/usr/bin/who -r`
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
457c478bd9Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
467c478bd9Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gateset -- `/usr/bin/uname -a`
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"  # Operating system name (uname -s)
517c478bd9Sstevel@tonic-gate_INIT_UTS_NODENAME="$2" # Node name (uname -n)
527c478bd9Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"  # Operating system release (uname -r)
537c478bd9Sstevel@tonic-gate_INIT_UTS_VERSION="$4"  # Operating system version (uname -v)
547c478bd9Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"  # Machine class (uname -m)
557c478bd9Sstevel@tonic-gate_INIT_UTS_ISA="$6"      # Instruction set architecture (uname -p)
567c478bd9Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7" # Platform string (uname -i)
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
597c478bd9Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
607c478bd9Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gateif [ -d /etc/rc0.d ]; then
637c478bd9Sstevel@tonic-gate	for f in /etc/rc0.d/K*; do
647c478bd9Sstevel@tonic-gate		if [ -s $f ]; then
657c478bd9Sstevel@tonic-gate			case $f in
667c478bd9Sstevel@tonic-gate				*.sh)	/lib/svc/bin/lsvcrun -s $f stop;;
677c478bd9Sstevel@tonic-gate				*)	/lib/svc/bin/lsvcrun $f stop;;
687c478bd9Sstevel@tonic-gate			esac
697c478bd9Sstevel@tonic-gate		fi
707c478bd9Sstevel@tonic-gate	done
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate	# System cleanup functions ONLY (things that end fast!)
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate	for f in /etc/rc0.d/S*; do
757c478bd9Sstevel@tonic-gate		if [ -s $f ]; then
767c478bd9Sstevel@tonic-gate			case $f in
777c478bd9Sstevel@tonic-gate				*.sh)	/lib/svc/bin/lsvcrun -s	 $f start;;
787c478bd9Sstevel@tonic-gate				*)	/lib/svc/bin/lsvcrun $f start ;;
797c478bd9Sstevel@tonic-gate			esac
807c478bd9Sstevel@tonic-gate		fi
817c478bd9Sstevel@tonic-gate	done
827c478bd9Sstevel@tonic-gatefi
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate[ -f /etc/.dynamic_routing ] && /usr/bin/rm -f /etc/.dynamic_routing
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gatetrap "" 15
87