Print this page
104 Bring back lx brand
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/zoneadm/svc-zones
+++ new/usr/src/cmd/zoneadm/svc-zones
1 1 #!/sbin/sh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
21 21 #
22 22 #
23 23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 24
25 25 . /lib/svc/share/smf_include.sh
26 26
27 27 #
28 28 # Return a list of running, non-global zones for which a shutdown via
29 29 # "/sbin/init 0" may work (typically only Solaris zones.)
30 30 #
31 +# At present, this means any running "lx" zones don't qualify.
32 +#
31 33 shutdown_zones()
32 34 {
33 35 zoneadm list -p | nawk -F: '{
34 - if ($2 != "global") {
36 + if (($5 != "lx") && ($2 != "global")) {
35 37 print $2
36 38 }
37 39 }'
38 40 }
39 41
40 42 [ ! -x /usr/sbin/zoneadm ] && exit 0 # SUNWzoneu not installed
41 43
42 44 if [ -z "$SMF_FMRI" ]; then
43 45 echo "this script can only be invoked by smf(5)"
44 46 exit $SMF_EXIT_ERR_NOSMF
45 47 fi
46 48
47 49 # Make sure working directory is / to prevent unmounting problems.
48 50 cd /
49 51 PATH=/usr/sbin:/usr/bin; export PATH
50 52
51 53 case "$1" in
52 54 'start')
53 55 egrep -vs '^#|^global:' /etc/zones/index || exit 0 # no local zones
54 56
55 57 #
56 58 # Boot the installed zones for which the "autoboot" zone property is
57 59 # set and invoke the sysboot hook for all other installed zones.
58 60 #
59 61 ZONES=""
60 62 for zone in `zoneadm list -pi | nawk -F: '{
61 63 if ($3 == "installed") {
62 64 print $2
63 65 }
64 66 }'`; do
65 67 zonecfg -z $zone info autoboot | grep "true" >/dev/null 2>&1
66 68 if [ $? -eq 0 ]; then
67 69 [ -z "$ZONES" ] && echo "Booting zones:\c"
68 70 ZONES=yes
69 71 echo " $zone\c"
70 72 #
71 73 # zoneadmd puts itself into its own contract so
72 74 # this service will lose sight of it. We don't
73 75 # support restart so it is OK for zoneadmd to
74 76 # to be in an orphaned contract.
75 77 #
76 78 zoneadm -z $zone boot &
77 79 else
78 80 zoneadm -z $zone sysboot &
79 81 fi
80 82 done
81 83
82 84 #
83 85 # Wait for all zoneadm processes to finish before allowing the
84 86 # start method to exit.
85 87 #
86 88 wait
87 89 [ -n "$ZONES" ] && echo .
88 90 ;;
89 91
90 92 'stop')
91 93 egrep -vs '^#|^global:' /etc/zones/index || exit 0 # no local zones
92 94 [ "`zoneadm list`" = "global" ] && exit 0 # no zones running
93 95
94 96 SVC_TIMEOUT=`svcprop -p stop/timeout_seconds $SMF_FMRI`
95 97
96 98 #
97 99 # First, try shutting down any running zones for which an "init 0" may
98 100 # work.
99 101 #
100 102 MAXSHUT=`expr 3 \* $SVC_TIMEOUT \/ 4` # 3/4 of time to zone shutdown
101 103 MAXHALT=`expr $SVC_TIMEOUT \/ 4` # rest of time goes to halt
102 104
103 105 zonelist=`shutdown_zones`
104 106
105 107 if [ -n "$zonelist" ]; then
106 108 SHUTDOWN=0
107 109 echo "Shutting down running zones (for up to $MAXSHUT" \
108 110 "seconds):\c"
109 111
110 112 for zone in $zonelist; do
111 113 echo " $zone\c"
112 114 zlogin -S $zone /sbin/init 0 < /dev/null >&0 2>&0 &
113 115 SHUTDOWN=1
114 116 done
115 117
116 118 [ $SHUTDOWN -eq 1 ] && echo "."
117 119
118 120 # Allow time for zones to shutdown cleanly
119 121
120 122 while [ $MAXSHUT -gt 0 -a "`shutdown_zones`" != "" ]; do
121 123 MAXSHUT=`expr $MAXSHUT - 1`
122 124 sleep 1 # wait a bit longer
123 125 done
124 126 fi
125 127
126 128 #
127 129 # Second, try halting any non-global zones still running
128 130 #
129 131 WAITPIDS=""
130 132 for zone in `zoneadm list`; do
131 133 if [ "$zone" != "global" ]; then
132 134 [ -z "$WAITPIDS" ] &&
133 135 echo "Zones failed to shutdown; trying to halt " \
134 136 "(for up to $MAXHALT seconds):\c"
135 137 echo " $zone\c"
136 138 zoneadm -z $zone halt &
137 139 WAITPIDS="$WAITPIDS $!"
138 140 fi
139 141 done
140 142 [ ! -z "$WAITPIDS" ] && echo .
141 143
142 144 # Wait for the 'zoneadm halt' commands to complete. We will let this
143 145 # run forever, since the restart daemon will eventually kill us off
144 146 # anyway if the halts do not complete after a certain period of time.
145 147 wait $WAITPIDS
146 148
147 149 # If the halts complete but a zone is still not shutdown, it might
148 150 # be in a state like 'shutting_down' or 'down'. So we give it some
149 151 # time to come all the way down.
150 152
151 153 while [ $MAXHALT -gt 0 -a "`zoneadm list`" != "global" ]; do
152 154 MAXHALT=`expr $MAXHALT - 1`
153 155 sleep 1 # wait a bit longer
154 156 done
155 157
156 158 # If there are any remaining file systems in zones, try to unmount them.
157 159 umountall -Z
158 160
159 161 #
160 162 # Report on zones which failed to shutdown.
161 163 #
162 164 for zone in `zoneadm list`; do
163 165 if [ "$zone" != "global" ]; then
164 166 echo "Zone '$zone' failed to halt."
165 167 fi
166 168 done
167 169 [ "`zoneadm list`" != "global" ] && exit 1 # zones still running
168 170 ;;
169 171
170 172 *)
171 173 echo "Usage: $0 { start | stop }"
172 174 exit 1
173 175 ;;
174 176 esac
175 177 exit 0
↓ open down ↓ |
131 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX