xref: /titanic_41/usr/src/cmd/initpkg/rc1.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 1
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gateif [ -z "$SMF_RESTARTER" ]; then
36*7c478bd9Sstevel@tonic-gate	echo "Cannot be run outside smf(5)"
37*7c478bd9Sstevel@tonic-gate	exit 1
38*7c478bd9Sstevel@tonic-gatefi
39*7c478bd9Sstevel@tonic-gate
40*7c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gatePATH=/usr/sbin:/usr/bin
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. /lib/svc/share/fs_include.sh
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gatecase $action in
71*7c478bd9Sstevel@tonic-gate	stop)
72*7c478bd9Sstevel@tonic-gate		>/etc/nologin
73*7c478bd9Sstevel@tonic-gate
74*7c478bd9Sstevel@tonic-gate		# All remote filesystem services must be explicitly disabled
75*7c478bd9Sstevel@tonic-gate		# at init run level 1, and at the single-user milestone.
76*7c478bd9Sstevel@tonic-gate
77*7c478bd9Sstevel@tonic-gate		if [ -d /etc/rc1.d ]; then
78*7c478bd9Sstevel@tonic-gate			for f in /etc/rc1.d/K*; do
79*7c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
80*7c478bd9Sstevel@tonic-gate					continue;
81*7c478bd9Sstevel@tonic-gate				fi
82*7c478bd9Sstevel@tonic-gate
83*7c478bd9Sstevel@tonic-gate				case $f in
84*7c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f stop
85*7c478bd9Sstevel@tonic-gate						;;
86*7c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f stop ;;
87*7c478bd9Sstevel@tonic-gate				esac
88*7c478bd9Sstevel@tonic-gate			done
89*7c478bd9Sstevel@tonic-gate		fi
90*7c478bd9Sstevel@tonic-gate
91*7c478bd9Sstevel@tonic-gate		;;
92*7c478bd9Sstevel@tonic-gate
93*7c478bd9Sstevel@tonic-gate	start)
94*7c478bd9Sstevel@tonic-gate		if [ -d /etc/rc1.d ]; then
95*7c478bd9Sstevel@tonic-gate			for f in /etc/rc1.d/S*; do
96*7c478bd9Sstevel@tonic-gate				if [ ! -s $f ]; then
97*7c478bd9Sstevel@tonic-gate					continue;
98*7c478bd9Sstevel@tonic-gate				fi
99*7c478bd9Sstevel@tonic-gate
100*7c478bd9Sstevel@tonic-gate				case $f in
101*7c478bd9Sstevel@tonic-gate					*.sh)	/lib/svc/bin/lsvcrun -s $f start
102*7c478bd9Sstevel@tonic-gate						;;
103*7c478bd9Sstevel@tonic-gate					*)	/lib/svc/bin/lsvcrun $f start ;;
104*7c478bd9Sstevel@tonic-gate				esac
105*7c478bd9Sstevel@tonic-gate			done
106*7c478bd9Sstevel@tonic-gate		fi
107*7c478bd9Sstevel@tonic-gate
108*7c478bd9Sstevel@tonic-gate		;;
109*7c478bd9Sstevel@tonic-gate
110*7c478bd9Sstevel@tonic-gate	*)
111*7c478bd9Sstevel@tonic-gate		echo "Usage: $0 { start | stop }"
112*7c478bd9Sstevel@tonic-gate		exit $SMF_EXIT_ERR_CONFIG
113*7c478bd9Sstevel@tonic-gate		;;
114*7c478bd9Sstevel@tonic-gateesac
115*7c478bd9Sstevel@tonic-gate
116*7c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK
117