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