Print this page
XXX Remove nawk(1)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/lvm/etc/svm.cleanup.sh
+++ new/usr/src/cmd/lvm/etc/svm.cleanup.sh
1 1 #! /usr/bin/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, Version 1.0 only
7 7 # (the "License"). You may not use this file except in compliance
8 8 # with the License.
9 9 #
10 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 11 # or http://www.opensolaris.org/os/licensing.
12 12 # See the License for the specific language governing permissions
13 13 # and limitations under the License.
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 #
15 15 # When distributing Covered Code, include this CDDL HEADER in each
16 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 17 # If applicable, add the following below this CDDL HEADER, with the
18 18 # fields enclosed by brackets "[]" replaced with your own identifying
19 19 # information: Portions Copyright [yyyy] [name of copyright owner]
20 20 #
21 21 # CDDL HEADER END
22 22 #
23 23 #
24 -# ident "%Z%%M% %I% %E% SMI"
25 -#
26 24 # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 25 # Use is subject to license terms.
28 26 #
29 27 # SVM Flash cleanup
30 28 # Remove existing master SVM configuration on clone after full flash install.
31 29 # Restore existing clone SVM configuation after differential flash install.
32 30 #
33 31
34 32 IN_SYS=${FLASH_ROOT}/etc/system
35 33 IN_CONF=${FLASH_ROOT}/kernel/drv/md.conf
36 34 IN_CF=${FLASH_ROOT}/etc/lvm/mddb.cf
37 35
38 36 TMP_SYS=/var/tmp/system.1
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
39 37 TMP_CONF=/var/tmp/md.conf.1
40 38 TMP_CF=/var/tmp/mddb.cf.1
41 39
42 40 # Directory where original clone config is saved.
43 41 SAVE_DIR=${FLASH_DIR}/flash/svm
44 42
45 43 if [ "${FLASH_TYPE}" = "FULL" ]; then
46 44 # Full flash install, remove master's SVM configuration from clone.
47 45
48 46 # Remove any SVM root entry from /etc/system file.
49 - nawk '
47 + /usr/xpg4/bin/awk '
50 48 BEGIN {delroot=0}
51 49 /^\* Begin MDD root info \(do not edit\)$/ {delroot=1}
52 50 /^\* End MDD root info \(do not edit\)$/ {delroot=0; next}
53 51 {if (delroot == 0) print $0}
54 52 ' ${IN_SYS} > ${TMP_SYS}
55 53 cp ${TMP_SYS} ${IN_SYS}
56 54
57 55 # Check if we are on the mini-root. If we are, we need to clean up the
58 56 # mddb configuration since this implies we are doing a full flash onto
59 57 # a fresh system.
60 58 #
61 59 # If we are not on the mini-root that must mean we are installing
62 60 # the full flash via live-upgrade. In that case we share the
63 61 # SVM configuration with the currently running system so we
64 62 # need to copy the md.conf file from the current root onto the
65 63 # newly installed root. Note that the flash archive might not have
66 64 # been created from the currently running system.
67 65 if [ -h /kernel/drv/md.conf ]; then
68 66 # Remove SVM mddb entries from /kernel/drv/md.conf.
69 - nawk '
67 + /usr/xpg4/bin/awk '
70 68 BEGIN {delmddb=0}
71 69 /^# Begin MDD database info \(do not edit\)$/ {delmddb=1}
72 70 /^# End MDD database info \(do not edit\)$/ {delmddb=0; next}
73 71 {if (delmddb == 0) print $0}
74 72 ' ${IN_CONF} > ${TMP_CONF}
75 73 cp ${TMP_CONF} ${IN_CONF}
76 74
77 75 # Remove SVM mddb entries from /etc/lvm/mddb.cf.
78 - nawk '
76 + /usr/xpg4/bin/awk '
79 77 /^#/ {print $0}
80 78 ' ${IN_CF} > ${TMP_CF}
81 79 cp ${TMP_CF} ${IN_CF}
82 80
83 81 else
84 82 # copy SVM config from current root to new root
85 83 cp /kernel/drv/md.conf ${IN_CONF}
86 84 cp /etc/lvm/mddb.cf ${IN_CF}
87 85 fi
88 86
89 87 # We may need to enable the SVM services in SMF. This could happen
90 88 # if we used jumpstart or live-upgrade to create SVM volumes as
91 89 # part of the flash install.
92 90 #
93 91 # It doesn't matter if we are doing a flash install via a jumpstart
94 92 # on the mini-root or via a live-upgrade. In both cases we check
95 93 # the md.conf on the currently running root to see if SVM is
96 94 # configured. For the jumpstart case it will have setup the
97 95 # volumes already so the mini-root md.conf has the mddb info. For
98 96 # the live-upgade case both roots will be sharing the same md.conf
99 97 # and have the same view of the SVM configuration.
100 98 #
101 99 # Check if there are mddb entries in md.conf to determine if SVM is
102 100 # configured.
103 101 sed -e 's/#.*$//' /kernel/drv/md.conf | \
104 102 egrep '^[ ]*mddb_bootlist' >/dev/null 2>&1
105 103 MDDB_STATUS=$?
106 104
107 105 if [ $MDDB_STATUS -eq 0 ]; then
108 106 echo "/usr/sbin/svcadm enable system/metainit:default" >> \
109 107 ${FLASH_ROOT}/var/svc/profile/upgrade
110 108
111 109 echo "/usr/sbin/svcadm enable system/mdmonitor:default" >> \
112 110 ${FLASH_ROOT}/var/svc/profile/upgrade
113 111
114 112 echo "/usr/sbin/svcadm enable network/rpc/meta:default" >> \
115 113 ${FLASH_ROOT}/var/svc/profile/upgrade
116 114 fi
117 115
118 116 else
119 117 # Differential flash install, restore clone SVM configuration.
120 118 # The matrix of master/clone SVM config w/ diff. flash looks like:
121 119 #
122 120 # master clone clone after differential flash
123 121 #
124 122 # yes yes same as clone prior to diff. flash
125 123 # yes no no
126 124 # no yes same as clone prior to diff. flash
127 125 # no no no
128 126 #
129 127
130 128 # restore saved config files
131 129 cp ${SAVE_DIR}/md.conf ${FLASH_ROOT}/kernel/drv/md.conf
132 130 cp ${SAVE_DIR}/devpath ${FLASH_ROOT}/etc/lvm/devpath
133 131 cp ${SAVE_DIR}/md.cf ${FLASH_ROOT}/etc/lvm/md.cf
134 132 cp ${SAVE_DIR}/md.ctlrmap ${FLASH_ROOT}/etc/lvm/md.ctlrmap
135 133 cp ${SAVE_DIR}/md.tab ${FLASH_ROOT}/etc/lvm/md.tab
136 134 cp ${SAVE_DIR}/mddb.cf ${FLASH_ROOT}/etc/lvm/mddb.cf
137 135 cp ${SAVE_DIR}/runtime.cf ${FLASH_ROOT}/etc/lvm/runtime.cf
138 136
↓ open down ↓ |
50 lines elided |
↑ open up ↑ |
139 137 # Now process the various permutations for the master and clone
140 138 # /etc/system file SVM root entries.
141 139
142 140 # First check if we need to do anything with /etc/system.
143 141 if `cmp -s ${SAVE_DIR}/system ${IN_SYS} >/dev/null 2>&1`; then
144 142 # There is no difference so leave it alone.
145 143 exit 0;
146 144 fi
147 145
148 146 # Get any SVM root entry from master /etc/system file.
149 - MASTER_ROOT=`nawk '
147 + MASTER_ROOT=`/usr/xpg4/bin/awk '
150 148 BEGIN {inroot=0}
151 149 /^\* Begin MDD root info \(do not edit\)$/ {inroot=1; next}
152 150 /^\* End MDD root info \(do not edit\)$/ {inroot=0}
153 151 {if (inroot == 1) print $0}
154 152 ' ${IN_SYS}`
155 153
156 154 # Get any SVM root entry from clone /etc/system file.
157 - CLONE_ROOT=`nawk '
155 + CLONE_ROOT=`/usr/xpg4/bin/awk '
158 156 BEGIN {inroot=0}
159 157 /^\* Begin MDD root info \(do not edit\)$/ {inroot=1; next}
160 158 /^\* End MDD root info \(do not edit\)$/ {inroot=0}
161 159 {if (inroot == 1) print $0}
162 160 ' ${SAVE_DIR}/system`
163 161
164 162 # If there is an SVM root entry in the master /etc/system file.
165 163 if [ "${MASTER_ROOT}" ]; then
166 164
167 165 # If there is an SVM root entry in the clone /etc/system file.
168 166 if [ "${CLONE_ROOT}" ]; then
169 167
170 168 # Restore clone SVM root entry in /etc/system file.
171 - nawk -v clone_root="${CLONE_ROOT}" '
169 + /usr/xpg4/bin/awk -v clone_root="${CLONE_ROOT}" '
172 170 BEGIN {newroot=0}
173 171 /^\* Begin MDD root info \(do not edit\)$/ {
174 172 newroot=1
175 173 print $0
176 174 print clone_root
177 175 }
178 176 /^\* End MDD root info \(do not edit\)$/ {newroot=0}
179 177 {if (newroot == 0) print $0}
180 178 ' ${IN_SYS} >${TMP_SYS}
181 179 cp ${TMP_SYS} ${IN_SYS}
182 180
183 181 else
184 182
185 183 # There is no SVM root entry in the clone so remove the entry
186 184 # from the /etc/system file.
187 - nawk '
185 + /usr/xpg4/bin/awk '
188 186 BEGIN {delroot=0}
189 187 /^\* Begin MDD root info \(do not edit\)$/ {delroot=1}
190 188 /^\* End MDD root info \(do not edit\)$/ {delroot=0; next }
191 189 {if (delroot == 0) print $0}
192 190 ' ${IN_SYS} >${TMP_SYS}
193 191 cp ${TMP_SYS} ${IN_SYS}
194 192
195 193 fi
196 194
197 195 else
198 196 # Master has no SVM root entry in the /etc/system file.
199 197 if [ "${CLONE_ROOT}" ]; then
200 198 # But clone does have one so we need to add it back in.
201 199
202 200 echo "* Begin MDD root info (do not edit)" >> ${IN_SYS}
203 201 echo "${CLONE_ROOT}" >> ${IN_SYS}
204 202 echo "* End MDD root info (do not edit)" >> ${IN_SYS}
205 203 fi
206 204
207 205 # If neither master nor clone has SVM root entry then
208 206 # we just leave the system file alone.
209 207 fi
210 208 fi
211 209
212 210 exit 0
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX