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 2017 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"
105 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
106 MEDIA
=`getvar install_media`
107 MEDIA
=`echo $MEDIA | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
108 MEDIA
=`echo $MEDIA | sed -e "s%///%//$BOOTSRVA/%g;"`
112 # ASSUME $2 is a file path.
114 # XXX KEBE SAYS, make switch statement based on $MEDIA's extension.
115 # e.g. "bz2" ==> "bzip -dc", "7z" ==>
119 zfs
set compression
=on
$RPOOL
120 zfs create
$RPOOL/ROOT
121 zfs
set canmount
=off
$RPOOL/ROOT
122 zfs
set mountpoint
=legacy
$RPOOL/ROOT
123 log
"Receiving image: $MEDIA"
124 $GRAB $MEDIA | pv
-B 128m
-w 78 |
$DECOMP | zfs receive
-u $RPOOL/ROOT
/unleashed
125 zfs
set canmount
=noauto
$RPOOL/ROOT
/unleashed
126 zfs
set mountpoint
=legacy
$RPOOL/ROOT
/unleashed
127 log
"Cleaning up boot environment"
128 beadm mount unleashed
/mnt
130 cp $ALTROOT/lib
/svc
/seed
/global.db
$ALTROOT/etc
/svc
/repository.db
131 chmod 0600 $ALTROOT/etc
/svc
/repository.db
132 chown root
:sys
$ALTROOT/etc
/svc
/repository.db
133 /usr
/sbin
/devfsadm
-r /mnt
134 [[ -L $ALTROOT/dev
/msglog
]] || \
135 ln -s ..
/devices
/pseudo
/sysmsg@
0:msglog
$ALTROOT/dev
/msglog
137 zfs destroy
$RPOOL/ROOT
/unleashed@kayak
142 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
143 CONFIG
=`getvar install_config`
144 CONFIG
=`echo $CONFIG | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
145 CONFIG
=`echo $CONFIG | sed -e "s%///%//$BOOTSRVA/%g;"`
147 while [[ "$L" -gt "0" ]]; do
148 URL
="$CONFIG/${ETHER:0:$L}"
149 log
"... trying $URL"
150 /bin
/curl
-s -o $ICFILE $URL
151 if [[ -f $ICFILE ]]; then
152 if [[ -n $
(grep BuildRpool
$ICFILE) ]]; then
153 log
"fetched config."
165 log
"Making boot environment bootable"
166 zpool
set bootfs
=$RPOOL/ROOT
/unleashed rpool
167 # Must do beadm activate first on the off chance we're bootstrapping from
169 beadm activate unleashed ||
return 1
171 if [[ ! -z $1 ]]; then
172 # Generate kayak-disk-list from zpool status.
173 # NOTE: If this is something on non-s0 slices, the installboot below
174 # will fail most likely, which is possibly a desired result.
175 zpool list
-v $RPOOL |
egrep -v "NAME|rpool|mirror" | \
176 awk '{print $1}' |
sed -E 's/s0$//g' > /tmp
/kayak-disk-list
179 # NOTE: This installboot loop assumes we're doing GPT whole-disk rpools.
180 for i
in `cat /tmp/kayak-disk-list`
182 installboot
-mfF /boot
/pmbr
/boot
/gptzfsboot
/dev
/rdsk
/${i}s0 ||
return 1
185 bootadm update-archive
-R $ALTROOT ||
return 1
191 log
"Setting hostname: ${1}"
193 echo "$1" > $ALTROOT/etc
/nodename
194 head -n 26 $ALTROOT/etc
/hosts
> /tmp
/hosts
195 echo "::1\t\t$1" >> /tmp
/hosts
196 echo "127.0.0.1\t$1" >> /tmp
/hosts
197 cat /tmp
/hosts
> $ALTROOT/etc
/hosts
202 macadr
=`/sbin/ifconfig -a | \
203 /usr/bin/awk '/UP/{if($2 !~ /LOOPBACK/){iface=$1;}} /ether/{if(iface){print $2; exit;}}' | \
204 /bin/tr '[:upper:]' '[:lower:]' | \
205 /bin/sed -e 's/^/ 0/g;s/:/-0/g; s/0\([0-9a-f][0-9a-f]\)/\1/g; s/ //g;'`
206 [ -z $suffix ] && suffix
=unleashed
207 [ "$suffix" == "-" ] && suffix
= || suffix
=-$suffix
208 SetHostname
$macadr$suffix
213 log
"Setting timezone: ${1}"
214 sed -i '' -e "s:^TZ=.*:TZ=${1}:" $ALTROOT/etc
/default
/init
219 log
"Setting language: ${1}"
220 sed -i '' -e "s:^LANG=.*:LANG=${1}:" $ALTROOT/etc
/default
/init
225 [[ -L $ALTROOT/etc
/svc
/profile
/generic.xml
]] || \
226 ln -s generic_limited_net.xml
$ALTROOT/etc
/svc
/profile
/generic.xml
227 [[ -L $ALTROOT/etc
/svc
/profile
/name_service.xml
]] || \
228 ln -s ns_dns.xml
$ALTROOT/etc
/svc
/profile
/name_service.xml
230 # Extras from interactive ISO/USB install...
232 if [[ ! -z $1 ]]; then
237 if [[ ! -z $2 ]]; then
242 if [[ ! -z $3 ]]; then
246 # arg4 == Keyboard layout
247 if [[ ! -z $4 ]]; then
248 # Even though /etc/default/kbd is now defunct, we instead use it
249 # For now, use it as the channel from the main menu to here, the
250 # installer. Extract LAYOUT=<foo> and put it in
251 # "setprop keyboard-layout <foo>" in the newly-installed root's
252 # /boot/solaris/bootenv.rc (aka. eeprom(1M) storage for amd64/i386).
254 sed "s/keyboard-layout Unknown/keyboard-layout $layout/g" \
255 < $ALTROOT/boot
/solaris
/bootenv.rc
> /tmp
/bootenv.rc
256 mv /tmp
/bootenv.rc
$ALTROOT/boot
/solaris
/bootenv.rc
257 # Also modify the SMF manifest, assuming US-English was set by default.
258 sed "s/US-English/$layout/g" \
259 < $ALTROOT/lib
/svc
/manifest
/system
/keymap.xml
> /tmp
/keymap.xml
260 cp -f /tmp
/keymap.xml
$ALTROOT/lib
/svc
/manifest
/system
/keymap.xml
267 [[ -f $ALTROOT/.initialboot
]] ||
touch $ALTROOT/.initialboot
268 echo "$*" >> $ALTROOT/.initialboot
272 # This is an awful hack... we already setup bootadm
273 # and we've likely deleted enough of the userspace that this
274 # can't run successfully... The easiest way to skip it is to
277 svccfg
-s "system/boot-config:default" setprop config
/fastreboot_default
=false
278 svcadm refresh svc
:/system
/boot-config
:default
283 FetchConfig || bomb
"Could not fetch kayak config for target"
284 # Set RPOOL if it wasn't done so already. We need it set.
285 RPOOL
=${RPOOL:-rpool}
287 Postboot
'exit $SMF_EXIT_OK'
288 ApplyChanges || bomb
"Could not apply all configuration changes"
289 MakeBootable || bomb
"Could not make new BE bootable"
290 log
"Install complete"