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 # ident "%Z%%M% %I% %E% SMI"
25 #
26 # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 # Use is subject to license terms.
28 #
29 # SVM Flash cleanup
30 # Remove existing master SVM configuration on clone after full flash install.
31 # Restore existing clone SVM configuation after differential flash install.
32 #
33
34 IN_SYS=${FLASH_ROOT}/etc/system
35 IN_CONF=${FLASH_ROOT}/kernel/drv/md.conf
36 IN_CF=${FLASH_ROOT}/etc/lvm/mddb.cf
37
38 TMP_SYS=/var/tmp/system.1
39 TMP_CONF=/var/tmp/md.conf.1
40 TMP_CF=/var/tmp/mddb.cf.1
41
42 # Directory where original clone config is saved.
43 SAVE_DIR=${FLASH_DIR}/flash/svm
44
45 if [ "${FLASH_TYPE}" = "FULL" ]; then
46 # Full flash install, remove master's SVM configuration from clone.
47
48 # Remove any SVM root entry from /etc/system file.
49 nawk '
50 BEGIN {delroot=0}
51 /^\* Begin MDD root info \(do not edit\)$/ {delroot=1}
52 /^\* End MDD root info \(do not edit\)$/ {delroot=0; next}
53 {if (delroot == 0) print $0}
54 ' ${IN_SYS} > ${TMP_SYS}
55 cp ${TMP_SYS} ${IN_SYS}
56
57 # Check if we are on the mini-root. If we are, we need to clean up the
58 # mddb configuration since this implies we are doing a full flash onto
59 # a fresh system.
60 #
61 # If we are not on the mini-root that must mean we are installing
62 # the full flash via live-upgrade. In that case we share the
63 # SVM configuration with the currently running system so we
64 # need to copy the md.conf file from the current root onto the
65 # newly installed root. Note that the flash archive might not have
66 # been created from the currently running system.
67 if [ -h /kernel/drv/md.conf ]; then
68 # Remove SVM mddb entries from /kernel/drv/md.conf.
69 nawk '
70 BEGIN {delmddb=0}
71 /^# Begin MDD database info \(do not edit\)$/ {delmddb=1}
72 /^# End MDD database info \(do not edit\)$/ {delmddb=0; next}
73 {if (delmddb == 0) print $0}
74 ' ${IN_CONF} > ${TMP_CONF}
75 cp ${TMP_CONF} ${IN_CONF}
76
77 # Remove SVM mddb entries from /etc/lvm/mddb.cf.
78 nawk '
79 /^#/ {print $0}
80 ' ${IN_CF} > ${TMP_CF}
81 cp ${TMP_CF} ${IN_CF}
82
83 else
84 # copy SVM config from current root to new root
85 cp /kernel/drv/md.conf ${IN_CONF}
86 cp /etc/lvm/mddb.cf ${IN_CF}
87 fi
88
89 # We may need to enable the SVM services in SMF. This could happen
90 # if we used jumpstart or live-upgrade to create SVM volumes as
91 # part of the flash install.
92 #
93 # It doesn't matter if we are doing a flash install via a jumpstart
94 # on the mini-root or via a live-upgrade. In both cases we check
95 # the md.conf on the currently running root to see if SVM is
96 # configured. For the jumpstart case it will have setup the
97 # volumes already so the mini-root md.conf has the mddb info. For
98 # the live-upgade case both roots will be sharing the same md.conf
129
130 # restore saved config files
131 cp ${SAVE_DIR}/md.conf ${FLASH_ROOT}/kernel/drv/md.conf
132 cp ${SAVE_DIR}/devpath ${FLASH_ROOT}/etc/lvm/devpath
133 cp ${SAVE_DIR}/md.cf ${FLASH_ROOT}/etc/lvm/md.cf
134 cp ${SAVE_DIR}/md.ctlrmap ${FLASH_ROOT}/etc/lvm/md.ctlrmap
135 cp ${SAVE_DIR}/md.tab ${FLASH_ROOT}/etc/lvm/md.tab
136 cp ${SAVE_DIR}/mddb.cf ${FLASH_ROOT}/etc/lvm/mddb.cf
137 cp ${SAVE_DIR}/runtime.cf ${FLASH_ROOT}/etc/lvm/runtime.cf
138
139 # Now process the various permutations for the master and clone
140 # /etc/system file SVM root entries.
141
142 # First check if we need to do anything with /etc/system.
143 if `cmp -s ${SAVE_DIR}/system ${IN_SYS} >/dev/null 2>&1`; then
144 # There is no difference so leave it alone.
145 exit 0;
146 fi
147
148 # Get any SVM root entry from master /etc/system file.
149 MASTER_ROOT=`nawk '
150 BEGIN {inroot=0}
151 /^\* Begin MDD root info \(do not edit\)$/ {inroot=1; next}
152 /^\* End MDD root info \(do not edit\)$/ {inroot=0}
153 {if (inroot == 1) print $0}
154 ' ${IN_SYS}`
155
156 # Get any SVM root entry from clone /etc/system file.
157 CLONE_ROOT=`nawk '
158 BEGIN {inroot=0}
159 /^\* Begin MDD root info \(do not edit\)$/ {inroot=1; next}
160 /^\* End MDD root info \(do not edit\)$/ {inroot=0}
161 {if (inroot == 1) print $0}
162 ' ${SAVE_DIR}/system`
163
164 # If there is an SVM root entry in the master /etc/system file.
165 if [ "${MASTER_ROOT}" ]; then
166
167 # If there is an SVM root entry in the clone /etc/system file.
168 if [ "${CLONE_ROOT}" ]; then
169
170 # Restore clone SVM root entry in /etc/system file.
171 nawk -v clone_root="${CLONE_ROOT}" '
172 BEGIN {newroot=0}
173 /^\* Begin MDD root info \(do not edit\)$/ {
174 newroot=1
175 print $0
176 print clone_root
177 }
178 /^\* End MDD root info \(do not edit\)$/ {newroot=0}
179 {if (newroot == 0) print $0}
180 ' ${IN_SYS} >${TMP_SYS}
181 cp ${TMP_SYS} ${IN_SYS}
182
183 else
184
185 # There is no SVM root entry in the clone so remove the entry
186 # from the /etc/system file.
187 nawk '
188 BEGIN {delroot=0}
189 /^\* Begin MDD root info \(do not edit\)$/ {delroot=1}
190 /^\* End MDD root info \(do not edit\)$/ {delroot=0; next }
191 {if (delroot == 0) print $0}
192 ' ${IN_SYS} >${TMP_SYS}
193 cp ${TMP_SYS} ${IN_SYS}
194
195 fi
196
197 else
198 # Master has no SVM root entry in the /etc/system file.
199 if [ "${CLONE_ROOT}" ]; then
200 # But clone does have one so we need to add it back in.
201
202 echo "* Begin MDD root info (do not edit)" >> ${IN_SYS}
203 echo "${CLONE_ROOT}" >> ${IN_SYS}
204 echo "* End MDD root info (do not edit)" >> ${IN_SYS}
205 fi
206
207 # If neither master nor clone has SVM root entry then
|
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 2005 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27 # SVM Flash cleanup
28 # Remove existing master SVM configuration on clone after full flash install.
29 # Restore existing clone SVM configuation after differential flash install.
30 #
31
32 IN_SYS=${FLASH_ROOT}/etc/system
33 IN_CONF=${FLASH_ROOT}/kernel/drv/md.conf
34 IN_CF=${FLASH_ROOT}/etc/lvm/mddb.cf
35
36 TMP_SYS=/var/tmp/system.1
37 TMP_CONF=/var/tmp/md.conf.1
38 TMP_CF=/var/tmp/mddb.cf.1
39
40 # Directory where original clone config is saved.
41 SAVE_DIR=${FLASH_DIR}/flash/svm
42
43 if [ "${FLASH_TYPE}" = "FULL" ]; then
44 # Full flash install, remove master's SVM configuration from clone.
45
46 # Remove any SVM root entry from /etc/system file.
47 /usr/xpg4/bin/awk '
48 BEGIN {delroot=0}
49 /^\* Begin MDD root info \(do not edit\)$/ {delroot=1}
50 /^\* End MDD root info \(do not edit\)$/ {delroot=0; next}
51 {if (delroot == 0) print $0}
52 ' ${IN_SYS} > ${TMP_SYS}
53 cp ${TMP_SYS} ${IN_SYS}
54
55 # Check if we are on the mini-root. If we are, we need to clean up the
56 # mddb configuration since this implies we are doing a full flash onto
57 # a fresh system.
58 #
59 # If we are not on the mini-root that must mean we are installing
60 # the full flash via live-upgrade. In that case we share the
61 # SVM configuration with the currently running system so we
62 # need to copy the md.conf file from the current root onto the
63 # newly installed root. Note that the flash archive might not have
64 # been created from the currently running system.
65 if [ -h /kernel/drv/md.conf ]; then
66 # Remove SVM mddb entries from /kernel/drv/md.conf.
67 /usr/xpg4/bin/awk '
68 BEGIN {delmddb=0}
69 /^# Begin MDD database info \(do not edit\)$/ {delmddb=1}
70 /^# End MDD database info \(do not edit\)$/ {delmddb=0; next}
71 {if (delmddb == 0) print $0}
72 ' ${IN_CONF} > ${TMP_CONF}
73 cp ${TMP_CONF} ${IN_CONF}
74
75 # Remove SVM mddb entries from /etc/lvm/mddb.cf.
76 /usr/xpg4/bin/awk '
77 /^#/ {print $0}
78 ' ${IN_CF} > ${TMP_CF}
79 cp ${TMP_CF} ${IN_CF}
80
81 else
82 # copy SVM config from current root to new root
83 cp /kernel/drv/md.conf ${IN_CONF}
84 cp /etc/lvm/mddb.cf ${IN_CF}
85 fi
86
87 # We may need to enable the SVM services in SMF. This could happen
88 # if we used jumpstart or live-upgrade to create SVM volumes as
89 # part of the flash install.
90 #
91 # It doesn't matter if we are doing a flash install via a jumpstart
92 # on the mini-root or via a live-upgrade. In both cases we check
93 # the md.conf on the currently running root to see if SVM is
94 # configured. For the jumpstart case it will have setup the
95 # volumes already so the mini-root md.conf has the mddb info. For
96 # the live-upgade case both roots will be sharing the same md.conf
127
128 # restore saved config files
129 cp ${SAVE_DIR}/md.conf ${FLASH_ROOT}/kernel/drv/md.conf
130 cp ${SAVE_DIR}/devpath ${FLASH_ROOT}/etc/lvm/devpath
131 cp ${SAVE_DIR}/md.cf ${FLASH_ROOT}/etc/lvm/md.cf
132 cp ${SAVE_DIR}/md.ctlrmap ${FLASH_ROOT}/etc/lvm/md.ctlrmap
133 cp ${SAVE_DIR}/md.tab ${FLASH_ROOT}/etc/lvm/md.tab
134 cp ${SAVE_DIR}/mddb.cf ${FLASH_ROOT}/etc/lvm/mddb.cf
135 cp ${SAVE_DIR}/runtime.cf ${FLASH_ROOT}/etc/lvm/runtime.cf
136
137 # Now process the various permutations for the master and clone
138 # /etc/system file SVM root entries.
139
140 # First check if we need to do anything with /etc/system.
141 if `cmp -s ${SAVE_DIR}/system ${IN_SYS} >/dev/null 2>&1`; then
142 # There is no difference so leave it alone.
143 exit 0;
144 fi
145
146 # Get any SVM root entry from master /etc/system file.
147 MASTER_ROOT=`/usr/xpg4/bin/awk '
148 BEGIN {inroot=0}
149 /^\* Begin MDD root info \(do not edit\)$/ {inroot=1; next}
150 /^\* End MDD root info \(do not edit\)$/ {inroot=0}
151 {if (inroot == 1) print $0}
152 ' ${IN_SYS}`
153
154 # Get any SVM root entry from clone /etc/system file.
155 CLONE_ROOT=`/usr/xpg4/bin/awk '
156 BEGIN {inroot=0}
157 /^\* Begin MDD root info \(do not edit\)$/ {inroot=1; next}
158 /^\* End MDD root info \(do not edit\)$/ {inroot=0}
159 {if (inroot == 1) print $0}
160 ' ${SAVE_DIR}/system`
161
162 # If there is an SVM root entry in the master /etc/system file.
163 if [ "${MASTER_ROOT}" ]; then
164
165 # If there is an SVM root entry in the clone /etc/system file.
166 if [ "${CLONE_ROOT}" ]; then
167
168 # Restore clone SVM root entry in /etc/system file.
169 /usr/xpg4/bin/awk -v clone_root="${CLONE_ROOT}" '
170 BEGIN {newroot=0}
171 /^\* Begin MDD root info \(do not edit\)$/ {
172 newroot=1
173 print $0
174 print clone_root
175 }
176 /^\* End MDD root info \(do not edit\)$/ {newroot=0}
177 {if (newroot == 0) print $0}
178 ' ${IN_SYS} >${TMP_SYS}
179 cp ${TMP_SYS} ${IN_SYS}
180
181 else
182
183 # There is no SVM root entry in the clone so remove the entry
184 # from the /etc/system file.
185 /usr/xpg4/bin/awk '
186 BEGIN {delroot=0}
187 /^\* Begin MDD root info \(do not edit\)$/ {delroot=1}
188 /^\* End MDD root info \(do not edit\)$/ {delroot=0; next }
189 {if (delroot == 0) print $0}
190 ' ${IN_SYS} >${TMP_SYS}
191 cp ${TMP_SYS} ${IN_SYS}
192
193 fi
194
195 else
196 # Master has no SVM root entry in the /etc/system file.
197 if [ "${CLONE_ROOT}" ]; then
198 # But clone does have one so we need to add it back in.
199
200 echo "* Begin MDD root info (do not edit)" >> ${IN_SYS}
201 echo "${CLONE_ROOT}" >> ${IN_SYS}
202 echo "* End MDD root info (do not edit)" >> ${IN_SYS}
203 fi
204
205 # If neither master nor clone has SVM root entry then
|