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
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.
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]
24 # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 # Use is subject to license terms.
37 if [[ -n "$INSTALL_LOG" ]]; then
38 cp $INSTALL_LOG $ALTROOT/var
/log
/install
/kayak.log
42 PUTURL
=`echo $CONFIG | sed -e 's%/kayak/%/kayaklog/%g;'`
43 PUTURL
=`echo $PUTURL | sed -e 's%/kayak$%/kayaklog%g;'`
44 curl
-T $INSTALL_LOG $PUTURL/$ETHER
47 if [[ "$LOG_SETUP" -eq "0" ]]; then
54 TS
=`date +%Y/%m/%d-%H:%M:%S`
60 log
======================================================
62 log
======================================================
63 if [[ -n "$INSTALL_LOG" ]]; then
64 log
"For more information, check $INSTALL_LOG"
65 log
======================================================
73 ICFILE
=/tmp
/_install_config
75 prtconf
-v /devices |
sed -n '/'$1'/{;n;p;}' | cut
-f2 -d\'
79 ROOTPW
='$5$kr1VgdIt$OUiUAyZCDogH/uaxH71rMeQxvpDEY2yX.x0ZQRnmeb9'
84 sed -i -e 's%^root::%root:'$ROOTPW':%' $ALTROOT/etc
/shadow
87 log
"Forcing all interfaces into DHCP..."
88 /sbin
/ifconfig
-a plumb
2> /dev
/null
90 for iface
in `/sbin/dladm show-phys -o device -p` ; do
91 /sbin
/ifconfig
$iface dhcp
&
93 while [[ -z $
(/sbin
/dhcpinfo BootSrvA
) ]]; do
94 log
"Waiting for dhcpinfo..."
97 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
98 log
"Next server: $BOOTSRVA"
103 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
104 MEDIA
=`getvar install_media`
105 MEDIA
=`echo $MEDIA | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
106 MEDIA
=`echo $MEDIA | sed -e "s%///%//$BOOTSRVA/%g;"`
107 zfs
set compression
=on rpool
108 zfs create rpool
/ROOT
109 zfs
set canmount
=off rpool
/ROOT
110 zfs
set mountpoint
=legacy rpool
/ROOT
111 log
"Receiving image: $MEDIA"
112 curl
-s $MEDIA | pv
-B 128m |
bzip2 -dc | zfs receive
-u rpool
/ROOT
/omnios
113 zfs
set canmount
=noauto rpool
/ROOT
/omnios
114 zfs
set mountpoint
=legacy rpool
/ROOT
/omnios
115 log
"Cleaning up boot environment"
116 beadm mount omnios
/mnt
118 cp $ALTROOT/lib
/svc
/seed
/global.db
$ALTROOT/etc
/svc
/repository.db
119 chmod 0600 $ALTROOT/etc
/svc
/repository.db
120 chown root
:sys
$ALTROOT/etc
/svc
/repository.db
121 /usr
/sbin
/devfsadm
-r /mnt
122 [[ -L $ALTROOT/dev
/msglog
]] || \
123 ln -s ..
/devices
/pseudo
/sysmsg@
0:msglog
$ALTROOT/dev
/msglog
125 zfs destroy rpool
/ROOT
/omnios@kayak
130 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
131 CONFIG
=`getvar install_config`
132 CONFIG
=`echo $CONFIG | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
133 CONFIG
=`echo $CONFIG | sed -e "s%///%//$BOOTSRVA/%g;"`
135 while [[ "$L" -gt "0" ]]; do
136 URL
="$CONFIG/${ETHER:0:$L}"
137 log
"... trying $URL"
138 /bin
/curl
-s -o $ICFILE $URL
139 if [[ -f $ICFILE ]]; then
140 if [[ -n $
(grep BuildRpool
$ICFILE) ]]; then
141 log
"fetched config."
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"
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
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
176 log
"Setting hostname: ${1}"
178 echo "$1" > $ALTROOT/etc
/nodename
179 head -n 26 $ALTROOT/etc
/hosts
> /tmp
/hosts
180 echo "::1\t\t$1" >> /tmp
/hosts
181 echo "127.0.0.1\t$1" >> /tmp
/hosts
182 cat /tmp
/hosts
> $ALTROOT/etc
/hosts
187 macadr
=`/sbin/ifconfig -a | \
188 /usr/bin/awk '/UP/{if($2 !~ /LOOPBACK/){iface=$1;}} /ether/{if(iface){print $2; exit;}}' | \
189 /bin/tr '[:upper:]' '[:lower:]' | \
190 /bin/sed -e 's/^/ 0/g;s/:/-0/g; s/0\([0-9a-f][0-9a-f]\)/\1/g; s/ //g;'`
191 [ -z $suffix ] && suffix
=omnios
192 [ "$suffix" == "-" ] && suffix
= || suffix
=-$suffix
193 SetHostname
$macadr$suffix
198 log
"Setting timezone: ${1}"
199 sed -i -e "s:^TZ=.*:TZ=${1}:" $ALTROOT/etc
/default
/init
204 [[ -L $ALTROOT/etc
/svc
/profile
/generic.xml
]] || \
205 ln -s generic_limited_net.xml
$ALTROOT/etc
/svc
/profile
/generic.xml
206 [[ -L $ALTROOT/etc
/svc
/profile
/name_service.xml
]] || \
207 ln -s ns_dns.xml
$ALTROOT/etc
/svc
/profile
/name_service.xml
212 [[ -f $ALTROOT/.initialboot
]] ||
touch $ALTROOT/.initialboot
213 echo "$*" >> $ALTROOT/.initialboot
217 # This is an awful hack... we already setup bootadm
218 # and we've likely deleted enough of the userspace that this
219 # can't run successfully... The easiest way to skip it is to
222 svccfg
-s "system/boot-config:default" setprop config
/fastreboot_default
=false
223 svcadm refresh svc
:/system
/boot-config
:default
228 FetchConfig || bomb
"Could not fecth kayak config for target"
230 Postboot
'exit $SMF_EXIT_OK'
231 ApplyChanges || bomb
"Could not apply all configuration changes"
232 MakeBootable || bomb
"Could not make new BE bootable"
233 log
"Install complete"