treewide: replace /sbin/sh hashbangs with /bin/sh
[unleashed.git] / usr / src / cmd / initpkg / rc2.sh
blob96e30e05405e20e3b5f283afa1001c90bae0e1c0
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 (c) 1984, 1986, 1987, 1988, 1989 AT&T.
24 # All rights reserved.
27 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
28 # Use is subject to license terms.
30 # ident "%Z%%M% %I% %E% SMI"
32 # Run Commands executed when the system is changing to init state 2,
33 # traditionally called "multi-user". Pick up start-up packages for mounts,
34 # daemons, services, etc.
36 PATH=/usr/sbin:/usr/bin
38 if [ -z "$SMF_RESTARTER" ]; then
39 echo "Cannot be run outside smf(5)"
40 exit 1
43 . /lib/svc/share/smf_include.sh
45 action=$1
47 # Export boot parameters to rc scripts
49 set -- `/usr/bin/who -r`
51 _INIT_RUN_LEVEL="$7" # Current run-level
52 _INIT_RUN_NPREV="$8" # Number of times previously at current run-level
53 _INIT_PREV_LEVEL="$9" # Previous run-level
55 set -- `/usr/bin/uname -a`
57 _INIT_UTS_SYSNAME="$1" # Operating system name (uname -s)
58 _INIT_UTS_NODENAME="$2" # Node name (uname -n)
59 _INIT_UTS_RELEASE="$3" # Operating system release (uname -r)
60 _INIT_UTS_VERSION="$4" # Operating system version (uname -v)
61 _INIT_UTS_MACHINE="$5" # Machine class (uname -m)
62 _INIT_UTS_ISA="$6" # Instruction set architecture (uname -p)
63 _INIT_UTS_PLATFORM="$7" # Platform string (uname -i)
65 export _INIT_RUN_LEVEL _INIT_RUN_NPREV _INIT_PREV_LEVEL \
66 _INIT_UTS_SYSNAME _INIT_UTS_NODENAME _INIT_UTS_RELEASE _INIT_UTS_VERSION \
67 _INIT_UTS_MACHINE _INIT_UTS_ISA _INIT_UTS_PLATFORM
70 # Set _INIT_NET_STRATEGY and _INIT_NET_IF variables from /sbin/netstrategy
72 smf_netstrategy
74 case $action in
75 stop)
76 if [ -d /etc/rc2.d ]; then
77 for f in /etc/rc2.d/K*; do
78 if [ ! -s $f ]; then
79 continue
82 case $f in
83 *.sh) /lib/svc/bin/lsvcrun -s $f \
84 stop ;;
85 *) /lib/svc/bin/lsvcrun $f stop ;;
86 esac
87 done
91 start)
92 for f in /etc/rc2.d/S*; do
93 if [ -s $f ]; then
94 case $f in
95 *.sh) /lib/svc/bin/lsvcrun -s $f \
96 start ;;
97 *) /lib/svc/bin/lsvcrun $f start ;;
98 esac
100 done
104 echo "Invalid argument"
105 exit 1
106 esac
108 if smf_is_globalzone; then
109 # enable full implicit device reconfig
110 /usr/sbin/devfsadm -S
113 exit 0