Unleashed v1.4
[unleashed.git] / usr / src / cmd / initpkg / rcS.sh
blob4171b074dcdec5a510ac25850f6dfef9dced27ab
1 #!/bin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
26 # ident "%Z%%M% %I% %E% SMI"
28 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
29 # All rights reserved.
33 # This file executes the commands in the rcS.d directory, which are necessary
34 # to get the system to single user mode:
36 # establish minimal network plumbing (for diskless and dataless)
37 # mount /usr (if a separate file system)
38 # set the system name
39 # check the root (/) and /usr file systems
40 # check and mount /var and /var/log (if a separate file system)
41 # mount pseudo file systems (/dev/fd)
42 # if this is a reconfiguration boot, [re]build the device entries
43 # check and mount other file systems to be mounted in single user mode
45 if [ -z "$SMF_RESTARTER" ]; then
46 echo "Cannot be run outside smf(5)"
47 exit 1
50 . /lib/svc/share/smf_include.sh
53 # Default definitions:
55 PATH=/usr/sbin:/usr/bin:/sbin
56 vfstab=/etc/vfstab
57 mnttab=/etc/mnttab
58 mntlist=
59 option=
60 otherops=
62 action=$1
64 # Export boot parameters to rc scripts
66 if [ "x$1" != xsysinit -a -d /usr/bin ]; then
67 set -- `/usr/bin/who -r`
69 _INIT_RUN_LEVEL=${7:-S} # Current run-level
70 _INIT_RUN_NPREV=${8:-0} # Number of times previously at current level
71 _INIT_PREV_LEVEL=${9:-0} # Previous run-level
72 else
73 _INIT_RUN_LEVEL=S
74 _INIT_RUN_NPREV=0
75 _INIT_PREV_LEVEL=0
78 set -- `/usr/bin/uname -a`
81 # If we're booting, uname -a will produce one fewer token than usual because
82 # the hostname has not yet been configured. Leave NODENAME empty in this case.
84 if [ $# -eq 7 ]; then
85 _INIT_UTS_SYSNAME="$1" # Operating system name (uname -s)
86 _INIT_UTS_NODENAME="$2" # Node name (uname -n)
87 shift 2
88 else
89 _INIT_UTS_SYSNAME="$1" # Operating system name (uname -s)
90 _INIT_UTS_NODENAME= # Node name is not yet configured
91 shift 1
94 _INIT_UTS_RELEASE="$1" # Operating system release (uname -r)
95 _INIT_UTS_VERSION="$2" # Operating system version (uname -v)
96 _INIT_UTS_MACHINE="$3" # Machine class (uname -m)
97 _INIT_UTS_ISA="$4" # Instruction set architecture (uname -p)
98 _INIT_UTS_PLATFORM="$5" # Platform string (uname -i)
100 export _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
101 _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
102 _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
105 # Set _INIT_NET_STRATEGY and _INIT_NET_IF variables from /sbin/netstrategy
107 smf_netstrategy
109 . /lib/svc/share/fs_include.sh
112 # Make the old, deprecated environment variable (_DVFS_RECONFIG) and the new
113 # supported environment variable (_INIT_RECONFIG) to be synonyms. Set both
114 # if the svc.startd reconfigure property is set. Note that for complete
115 # backwards compatibility the value "YES" is significant with _DVFS_RECONFIG.
116 # The # value associated with _INIT_RECONFIG is insignificant. What is
117 # significant is only that the environment variable is defined.
120 svcprop -q -p system/reconfigure system/svc/restarter:default
121 if [ $? -eq 0 ]
122 then
123 echo "Setting _INIT_RECONFIG."
124 _DVFS_RECONFIG=YES; export _DVFS_RECONFIG
125 _INIT_RECONFIG=set; export _INIT_RECONFIG
129 case $action in
130 stop)
131 >/etc/nologin
133 # All remote filesystem services must be explicitly disabled
134 # at the single-user milestone. There's no need to unmount
135 # remote filesystems here.
137 if [ -d /etc/rcS.d ]; then
138 for f in /etc/rcS.d/K*; do
139 if [ ! -s $f ]; then
140 continue
143 case $f in
144 *.sh) /lib/svc/bin/lsvcrun -s $f stop
146 *) /lib/svc/bin/lsvcrun $f stop ;;
147 esac
148 done
153 start)
154 if [ -d /etc/rcS.d ]; then
155 for f in /etc/rcS.d/S*; do
156 if [ ! -s $f ]; then
157 continue
160 case $f in
161 *.sh) /lib/svc/bin/lsvcrun -s $f start
163 *) /lib/svc/bin/lsvcrun $f start ;;
164 esac
165 done
169 # Clean up the /reconfigure file and sync the new entries to
170 # stable media.
173 # GLXXX - svc.startd should do this?
174 if [ -n "$_INIT_RECONFIG" ]; then
175 [ -f /reconfigure ] && /usr/bin/rm -f /reconfigure
176 /sbin/sync
181 echo "Usage: $0 { start | stop }"
182 exit $SMF_EXIT_ERR_CONFIG
184 esac
186 exit $SMF_EXIT_OK