xref: /onnv-gate/usr/src/cmd/initpkg/rc1.sh (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/sbin/sh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#
24*0Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
25*0Sstevel@tonic-gate# All rights reserved.
26*0Sstevel@tonic-gate#
27*0Sstevel@tonic-gate#
28*0Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
29*0Sstevel@tonic-gate# Use is subject to license terms.
30*0Sstevel@tonic-gate#
31*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate# "Run Commands" executed when the system is changing to init state 1
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
36*0Sstevel@tonic-gate	echo "Cannot be run outside smf(5)"
37*0Sstevel@tonic-gate	exit 1
38*0Sstevel@tonic-gatefi
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
41*0Sstevel@tonic-gate
42*0Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
43*0Sstevel@tonic-gate
44*0Sstevel@tonic-gateaction=$1
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gate# Export boot parameters to rc scripts
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gateset -- `/usr/bin/who -r`
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gate_INIT_RUN_LEVEL="$7"	# Current run-level
51*0Sstevel@tonic-gate_INIT_RUN_NPREV="$8"	# Number of times previously at current run-level
52*0Sstevel@tonic-gate_INIT_PREV_LEVEL="$9"	# Previous run-level
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gateset -- `/usr/bin/uname -a`
55*0Sstevel@tonic-gate
56*0Sstevel@tonic-gate_INIT_UTS_SYSNAME="$1"  # Operating system name (uname -s)
57*0Sstevel@tonic-gate_INIT_UTS_NODENAME="$2" # Node name (uname -n)
58*0Sstevel@tonic-gate_INIT_UTS_RELEASE="$3"  # Operating system release (uname -r)
59*0Sstevel@tonic-gate_INIT_UTS_VERSION="$4"  # Operating system version (uname -v)
60*0Sstevel@tonic-gate_INIT_UTS_MACHINE="$5"  # Machine class (uname -m)
61*0Sstevel@tonic-gate_INIT_UTS_ISA="$6"      # Instruction set architecture (uname -p)
62*0Sstevel@tonic-gate_INIT_UTS_PLATFORM="$7" # Platform string (uname -i)
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gateexport _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
65*0Sstevel@tonic-gate    _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
66*0Sstevel@tonic-gate    _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
67*0Sstevel@tonic-gate
68*0Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gatecase $action in
71*0Sstevel@tonic-gate	stop)
72*0Sstevel@tonic-gate		>/etc/nologin
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gate		# All remote filesystem services must be explicitly disabled
75*0Sstevel@tonic-gate		# at init run level 1, and at the single-user milestone.
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate		if [ -d /etc/rc1.d ]; then
78*0Sstevel@tonic-gate			for f in /etc/rc1.d/K*; do
79*0Sstevel@tonic-gate				if [ ! -s $f ]; then
80*0Sstevel@tonic-gate					continue;
81*0Sstevel@tonic-gate				fi
82*0Sstevel@tonic-gate
83*0Sstevel@tonic-gate				case $f in
84*0Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f stop
85*0Sstevel@tonic-gate						;;
86*0Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f stop ;;
87*0Sstevel@tonic-gate				esac
88*0Sstevel@tonic-gate			done
89*0Sstevel@tonic-gate		fi
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate		;;
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gate	start)
94*0Sstevel@tonic-gate		if [ -d /etc/rc1.d ]; then
95*0Sstevel@tonic-gate			for f in /etc/rc1.d/S*; do
96*0Sstevel@tonic-gate				if [ ! -s $f ]; then
97*0Sstevel@tonic-gate					continue;
98*0Sstevel@tonic-gate				fi
99*0Sstevel@tonic-gate
100*0Sstevel@tonic-gate				case $f in
101*0Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f start
102*0Sstevel@tonic-gate						;;
103*0Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f start ;;
104*0Sstevel@tonic-gate				esac
105*0Sstevel@tonic-gate			done
106*0Sstevel@tonic-gate		fi
107*0Sstevel@tonic-gate
108*0Sstevel@tonic-gate		;;
109*0Sstevel@tonic-gate
110*0Sstevel@tonic-gate	*)
111*0Sstevel@tonic-gate		echo "Usage: $0 { start | stop }"
112*0Sstevel@tonic-gate		exit $SMF_EXIT_ERR_CONFIG
113*0Sstevel@tonic-gate		;;
114*0Sstevel@tonic-gateesac
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gateexit $SMF_EXIT_OK
117