4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
28 if [[ -n "$INSTALL_LOG" ]]; then
29 cp $INSTALL_LOG $ALTROOT/var
/log
/install
/kayak.log
33 PUTURL
=`echo $CONFIG | sed -e 's%/kayak/%/kayaklog/%g;'`
34 PUTURL
=`echo $PUTURL | sed -e 's%/kayak$%/kayaklog%g;'`
35 curl
-T $INSTALL_LOG $PUTURL/$ETHER
38 if [[ "$LOG_SETUP" -eq "0" ]]; then
45 TS
=`date +%Y/%m/%d-%H:%M:%S`
51 log
======================================================
53 log
======================================================
54 if [[ -n "$INSTALL_LOG" ]]; then
55 log
"For more information, check $INSTALL_LOG"
56 log
======================================================
64 ICFILE
=/tmp
/_install_config
66 prtconf
-v /devices |
sed -n '/'$1'/{;n;p;}' | cut
-f2 -d\'
70 ROOTPW
='$5$kr1VgdIt$OUiUAyZCDogH/uaxH71rMeQxvpDEY2yX.x0ZQRnmeb9'
75 sed -i '' -e 's%^root:NP:%root:'$ROOTPW':%' $ALTROOT/etc
/shadow
78 log
"Forcing all interfaces into DHCP..."
79 /sbin
/ifconfig
-a plumb
2> /dev
/null
81 for iface
in `/sbin/dladm show-phys -o device -p` ; do
82 /sbin
/ifconfig
$iface dhcp
&
84 while [[ -z $
(/sbin
/dhcpinfo BootSrvA
) ]]; do
85 log
"Waiting for dhcpinfo..."
88 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
89 log
"Next server: $BOOTSRVA"
96 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
97 MEDIA
=`getvar install_media`
98 MEDIA
=`echo $MEDIA | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
99 MEDIA
=`echo $MEDIA | sed -e "s%///%//$BOOTSRVA/%g;"`
103 # ASSUME $2 is a file path. TODO: Parse the URL...
105 # TODO: make switch statement based on $MEDIA's extension.
106 # e.g. "bz2" ==> "bzip -dc", "7z" ==>
110 zfs
set compression
=on
$RPOOL
111 zfs create
$RPOOL/ROOT
112 zfs
set canmount
=off
$RPOOL/ROOT
113 zfs
set mountpoint
=legacy
$RPOOL/ROOT
114 log
"Receiving image: $MEDIA"
115 $GRAB $MEDIA | pv
-B 128m
-w 78 |
$DECOMP | zfs receive
-u $RPOOL/ROOT
/unleashed
116 zfs
set canmount
=noauto
$RPOOL/ROOT
/unleashed
117 zfs
set mountpoint
=legacy
$RPOOL/ROOT
/unleashed
118 log
"Cleaning up boot environment"
119 beadm mount unleashed
/mnt
121 cp $ALTROOT/lib
/svc
/seed
/global.db
$ALTROOT/etc
/svc
/repository.db
122 chmod 0600 $ALTROOT/etc
/svc
/repository.db
123 chown root
:sys
$ALTROOT/etc
/svc
/repository.db
124 /usr
/sbin
/devfsadm
-r /mnt
125 [[ -L $ALTROOT/dev
/msglog
]] || \
126 ln -s ..
/devices
/pseudo
/sysmsg@
0:msglog
$ALTROOT/dev
/msglog
128 zfs destroy
$RPOOL/ROOT
/unleashed@kayak
133 BOOTSRVA
=`/sbin/dhcpinfo BootSrvA`
134 CONFIG
=`getvar install_config`
135 CONFIG
=`echo $CONFIG | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
136 CONFIG
=`echo $CONFIG | sed -e "s%///%//$BOOTSRVA/%g;"`
138 while [[ "$L" -gt "0" ]]; do
139 URL
="$CONFIG/${ETHER:0:$L}"
140 log
"... trying $URL"
141 /bin
/curl
-s -o $ICFILE $URL
142 if [[ -f $ICFILE ]]; then
143 if [[ -n $
(grep BuildRpool
$ICFILE) ]]; then
144 log
"fetched config."
156 log
"Making boot environment bootable"
157 zpool
set bootfs
=$RPOOL/ROOT
/unleashed rpool
158 # Must do beadm activate first on the off chance we're bootstrapping from
160 beadm activate unleashed ||
return 1
162 if [[ ! -z $1 ]]; then
163 # Generate kayak-disk-list from zpool status.
164 # NOTE: If this is something on non-s0 slices, the installboot below
165 # will fail most likely, which is possibly a desired result.
166 zpool list
-v $RPOOL |
egrep -v "NAME|rpool|mirror" | \
167 awk '{print $1}' |
sed -E 's/s0$//g' > /tmp
/kayak-disk-list
170 # NOTE: This installboot loop assumes we're doing GPT whole-disk rpools.
171 for i
in `cat /tmp/kayak-disk-list`
173 installboot
-mfF /boot
/pmbr
/boot
/gptzfsboot
/dev
/rdsk
/${i}s0 ||
return 1
176 bootadm update-archive
-R $ALTROOT ||
return 1
182 log
"Setting hostname: ${1}"
184 echo "$1" > $ALTROOT/etc
/nodename
185 head -n 26 $ALTROOT/etc
/hosts
> /tmp
/hosts
186 echo "::1\t\t$1" >> /tmp
/hosts
187 echo "127.0.0.1\t$1" >> /tmp
/hosts
188 cat /tmp
/hosts
> $ALTROOT/etc
/hosts
193 macadr
=`/sbin/ifconfig -a | \
194 /usr/bin/awk '/UP/{if($2 !~ /LOOPBACK/){iface=$1;}} /ether/{if(iface){print $2; exit;}}' | \
195 /bin/tr '[:upper:]' '[:lower:]' | \
196 /bin/sed -e 's/^/ 0/g;s/:/-0/g; s/0\([0-9a-f][0-9a-f]\)/\1/g; s/ //g;'`
197 [ -z $suffix ] && suffix
=unleashed
198 [ "$suffix" == "-" ] && suffix
= || suffix
=-$suffix
199 SetHostname
$macadr$suffix
204 log
"Setting timezone: ${1}"
205 sed -i '' -e "s:^TZ=.*:TZ=${1}:" $ALTROOT/etc
/default
/init
210 log
"Setting language: ${1}"
211 sed -i '' -e "s:^LANG=.*:LANG=${1}:" $ALTROOT/etc
/default
/init
216 # Put the new keyboard layout ($1) in
217 # "setprop keyboard-layout <foo>" in the newly-installed root's
218 # /boot/solaris/bootenv.rc (aka. eeprom(1M) storage for amd64/i386).
220 sed "s/keyboard-layout Unknown/keyboard-layout $layout/g" \
221 < $ALTROOT/boot
/solaris
/bootenv.rc
> /tmp
/bootenv.rc
222 mv /tmp
/bootenv.rc
$ALTROOT/boot
/solaris
/bootenv.rc
223 # Also modify the SMF manifest, assuming US-English was set by default.
224 sed "s/US-English/$layout/g" \
225 < $ALTROOT/lib
/svc
/manifest
/system
/keymap.xml
> /tmp
/keymap.xml
226 cp -f /tmp
/keymap.xml
$ALTROOT/lib
/svc
/manifest
/system
/keymap.xml
231 [[ -L $ALTROOT/etc
/svc
/profile
/generic.xml
]] || \
232 ln -s generic_limited_net.xml
$ALTROOT/etc
/svc
/profile
/generic.xml
233 [[ -L $ALTROOT/etc
/svc
/profile
/name_service.xml
]] || \
234 ln -s ns_dns.xml
$ALTROOT/etc
/svc
/profile
/name_service.xml
236 # Extras from interactive ISO/USB install...
238 if [[ ! -z $1 ]]; then
243 if [[ ! -z $2 ]]; then
248 if [[ ! -z $3 ]]; then
252 # arg4 == Keyboard layout
253 if [[ ! -z $4 ]]; then
261 # This is an awful hack... we already setup bootadm
262 # and we've likely deleted enough of the userspace that this
263 # can't run successfully... The easiest way to skip it is to
266 svccfg
-s "system/boot-config:default" setprop config
/fastreboot_default
=false
267 svcadm refresh svc
:/system
/boot-config
:default
272 FetchConfig || bomb
"Could not fetch kayak config for target"
273 # Set RPOOL if it wasn't done so already. We need it set.
274 RPOOL
=${RPOOL:-rpool}
276 Postboot
'exit $SMF_EXIT_OK'
277 ApplyChanges || bomb
"Could not apply all configuration changes"
278 MakeBootable || bomb
"Could not make new BE bootable"
279 log
"Install complete"