Print this page
Have kayak install full-GPT disks and use BSD Loader
| Split |
Close |
| Expand all |
| Collapse all |
--- old/install_help.sh
+++ new/install_help.sh
1 1 #!/usr/bin/bash
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.
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 24 # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27 LOG_SETUP=0
28 28
29 29 ConsoleLog(){
30 30 exec 4>/dev/console
31 31 exec 1>>${1}
32 32 exec 2>>${1}
33 33 INSTALL_LOG=${1}
34 34 LOG_SETUP=1
35 35 }
36 36 CopyInstallLog(){
37 37 if [[ -n "$INSTALL_LOG" ]]; then
38 38 cp $INSTALL_LOG $ALTROOT/var/log/install/kayak.log
39 39 fi
40 40 }
41 41 SendInstallLog(){
42 42 PUTURL=`echo $CONFIG | sed -e 's%/kayak/%/kayaklog/%g;'`
43 43 PUTURL=`echo $PUTURL | sed -e 's%/kayak$%/kayaklog%g;'`
44 44 curl -T $INSTALL_LOG $PUTURL/$ETHER
45 45 }
46 46 OutputLog(){
47 47 if [[ "$LOG_SETUP" -eq "0" ]]; then
48 48 exec 4>/dev/null
49 49 LOG_SETUP=1
50 50 fi
51 51 }
52 52 log() {
53 53 OutputLog
54 54 TS=`date +%Y/%m/%d-%H:%M:%S`
55 55 echo "[$TS] $*" 1>&4
56 56 echo "[$TS] $*"
57 57 }
58 58 bomb() {
59 59 log
60 60 log ======================================================
61 61 log "$*"
62 62 log ======================================================
63 63 if [[ -n "$INSTALL_LOG" ]]; then
64 64 log "For more information, check $INSTALL_LOG"
65 65 log ======================================================
66 66 fi
67 67 exit 1
68 68 }
69 69
70 70 . /kayak/net_help.sh
71 71 . /kayak/disk_help.sh
72 72
73 73 ICFILE=/tmp/_install_config
74 74 getvar(){
75 75 prtconf -v /devices | sed -n '/'$1'/{;n;p;}' | cut -f2 -d\'
76 76 }
77 77
78 78 # Blank
79 79 ROOTPW='$5$kr1VgdIt$OUiUAyZCDogH/uaxH71rMeQxvpDEY2yX.x0ZQRnmeb9'
80 80 RootPW(){
81 81 ROOTPW="$1"
82 82 }
83 83 SetRootPW(){
84 84 sed -i -e 's%^root::%root:'$ROOTPW':%' $ALTROOT/etc/shadow
85 85 }
86 86 ForceDHCP(){
87 87 log "Forcing all interfaces into DHCP..."
88 88 /sbin/ifconfig -a plumb 2> /dev/null
89 89 # for the logs
90 90 for iface in `/sbin/dladm show-phys -o device -p` ; do
91 91 /sbin/ifconfig $iface dhcp &
92 92 done
93 93 while [[ -z $(/sbin/dhcpinfo BootSrvA) ]]; do
94 94 log "Waiting for dhcpinfo..."
95 95 sleep 1
96 96 done
97 97 BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
98 98 log "Next server: $BOOTSRVA"
99 99 sleep 1
100 100 }
101 101
102 102 BuildBE() {
103 103 BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
104 104 MEDIA=`getvar install_media`
105 105 MEDIA=`echo $MEDIA | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
106 106 MEDIA=`echo $MEDIA | sed -e "s%///%//$BOOTSRVA/%g;"`
107 107 zfs set compression=on rpool
108 108 zfs create rpool/ROOT
109 109 zfs set canmount=off rpool/ROOT
110 110 zfs set mountpoint=legacy rpool/ROOT
111 111 log "Receiving image: $MEDIA"
112 112 curl -s $MEDIA | pv -B 128m | bzip2 -dc | zfs receive -u rpool/ROOT/omnios
113 113 zfs set canmount=noauto rpool/ROOT/omnios
114 114 zfs set mountpoint=legacy rpool/ROOT/omnios
115 115 log "Cleaning up boot environment"
116 116 beadm mount omnios /mnt
117 117 ALTROOT=/mnt
118 118 cp $ALTROOT/lib/svc/seed/global.db $ALTROOT/etc/svc/repository.db
119 119 chmod 0600 $ALTROOT/etc/svc/repository.db
120 120 chown root:sys $ALTROOT/etc/svc/repository.db
121 121 /usr/sbin/devfsadm -r /mnt
122 122 [[ -L $ALTROOT/dev/msglog ]] || \
123 123 ln -s ../devices/pseudo/sysmsg@0:msglog $ALTROOT/dev/msglog
124 124 MakeSwapDump
125 125 zfs destroy rpool/ROOT/omnios@kayak
126 126 }
127 127
128 128 FetchConfig(){
129 129 ETHER=`Ether`
130 130 BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
131 131 CONFIG=`getvar install_config`
132 132 CONFIG=`echo $CONFIG | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
133 133 CONFIG=`echo $CONFIG | sed -e "s%///%//$BOOTSRVA/%g;"`
134 134 L=${#ETHER}
135 135 while [[ "$L" -gt "0" ]]; do
136 136 URL="$CONFIG/${ETHER:0:$L}"
137 137 log "... trying $URL"
138 138 /bin/curl -s -o $ICFILE $URL
139 139 if [[ -f $ICFILE ]]; then
140 140 if [[ -n $(grep BuildRpool $ICFILE) ]]; then
141 141 log "fetched config."
142 142 return 0
|
↓ open down ↓ |
142 lines elided |
↑ open up ↑ |
143 143 fi
144 144 rm -f $ICFILE
145 145 fi
146 146 L=$(($L - 1))
147 147 done
148 148 return 1
149 149 }
150 150
151 151 MakeBootable(){
152 152 log "Making boot environment bootable"
153 - mkdir -p /rpool/boot/grub/bootsign || bomb "mkdir rpool/boot/grub failed"
154 - touch /rpool/boot/grub/bootsign/pool_rpool || bomb "making bootsign failed"
155 - chown -R root:root /rpool/boot || bomb "rpool/boot chown failed"
156 - chmod 444 /rpool/boot/grub/bootsign/pool_rpool || bomb "chmod bootsign failed"
157 - for f in capability menu.lst splash.xpm.gz ; do
158 - cp -p $ALTROOT/boot/grub/$f /rpool/boot/grub/$f || \
159 - bomb "setup rpool/boot/grub/$f failed"
153 + zpool set bootfs=rpool/ROOT/omnios rpool
154 + # Must do beadm activate first on the off chance we're bootstrapping from
155 + # GRUB.
156 + beadm activate omnios
157 +
158 + # NOTE: This installboot loop assumes we're doing GPT whole-disk rpools.
159 + for i in `cat /tmp/kayak-disk-list`
160 + do
161 + installboot -mf /boot/pmbr /boot/gptzfsboot /dev/rdsk/${i}s0
160 162 done
161 - zpool set bootfs=rpool/ROOT/omnios rpool || bomb "setting bootfs failed"
162 - beadm activate omnios || bomb "activating be failed"
163 - $ALTROOT/boot/solaris/bin/update_grub -R $ALTROOT
163 +
164 164 bootadm update-archive -R $ALTROOT
165 - RELEASE=`head -1 $ALTROOT/etc/release | sed -e 's/ *//;'`
166 - sed -i -e '/BOOTADM/,/BOOTADM/d' /rpool/boot/grub/menu.lst
167 - sed -i -e "s/^title.*/title $RELEASE/;" /rpool/boot/grub/menu.lst
168 - SendInstallLog
169 - CopyInstallLog
170 - beadm umount omnios
171 165 return 0
172 166 }
173 167
174 168 SetHostname()
175 169 {
176 170 log "Setting hostname: ${1}"
177 171 /bin/hostname "$1"
178 172 echo "$1" > $ALTROOT/etc/nodename
179 173 head -n 26 $ALTROOT/etc/hosts > /tmp/hosts
180 174 echo "::1\t\t$1" >> /tmp/hosts
181 175 echo "127.0.0.1\t$1" >> /tmp/hosts
182 176 cat /tmp/hosts > $ALTROOT/etc/hosts
183 177 }
184 178
185 179 AutoHostname() {
186 180 suffix=$1
187 181 macadr=`/sbin/ifconfig -a | \
188 182 /usr/bin/awk '/UP/{if($2 !~ /LOOPBACK/){iface=$1;}} /ether/{if(iface){print $2; exit;}}' | \
189 183 /bin/tr '[:upper:]' '[:lower:]' | \
190 184 /bin/sed -e 's/^/ 0/g;s/:/-0/g; s/0\([0-9a-f][0-9a-f]\)/\1/g; s/ //g;'`
191 185 [ -z $suffix ] && suffix=omnios
192 186 [ "$suffix" == "-" ] && suffix= || suffix=-$suffix
193 187 SetHostname $macadr$suffix
194 188 }
195 189
196 190 SetTimezone()
197 191 {
198 192 log "Setting timezone: ${1}"
199 193 sed -i -e "s:^TZ=.*:TZ=${1}:" $ALTROOT/etc/default/init
200 194 }
201 195
202 196 ApplyChanges(){
203 197 SetRootPW
204 198 [[ -L $ALTROOT/etc/svc/profile/generic.xml ]] || \
205 199 ln -s generic_limited_net.xml $ALTROOT/etc/svc/profile/generic.xml
206 200 [[ -L $ALTROOT/etc/svc/profile/name_service.xml ]] || \
207 201 ln -s ns_dns.xml $ALTROOT/etc/svc/profile/name_service.xml
208 202 return 0
209 203 }
210 204
211 205 Postboot() {
212 206 [[ -f $ALTROOT/.initialboot ]] || touch $ALTROOT/.initialboot
213 207 echo "$*" >> $ALTROOT/.initialboot
214 208 }
215 209
216 210 Reboot() {
217 211 # This is an awful hack... we already setup bootadm
218 212 # and we've likely deleted enough of the userspace that this
219 213 # can't run successfully... The easiest way to skip it is to
220 214 # remove the binary
221 215 rm -f /sbin/bootadm
222 216 svccfg -s "system/boot-config:default" setprop config/fastreboot_default=false
223 217 svcadm refresh svc:/system/boot-config:default
224 218 reboot
225 219 }
226 220
227 221 RunInstall(){
228 222 FetchConfig || bomb "Could not fecth kayak config for target"
229 223 . $ICFILE
230 224 Postboot 'exit $SMF_EXIT_OK'
231 225 ApplyChanges || bomb "Could not apply all configuration changes"
232 226 MakeBootable || bomb "Could not make new BE bootable"
233 227 log "Install complete"
234 228 return 0
235 229 }
|
↓ open down ↓ |
55 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX