Print this page
Kayak for ISO.
Starting with this commit, "gmake install-usb" will build the entire Kayak
world, both for PXE boot and for USB/ISO installers as well.
The CDDL license text and copyrights for OmniTI-original code are now
updated, too.
Additionally, there are files now present to allow pxeboot (Loader's PXE
booter) instead of pxegrub (GRUB's PXE booter).
Some portions Reviewed by: Lauri Tirkkonen <lotheac@iki.fi>

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 +# 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
        7 +# 1.0 of the CDDL.
   4    8  #
   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 +# 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.
   9   12  #
  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.
       13 +
  14   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]
       15 +# Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
  20   16  #
  21      -# CDDL HEADER END
  22      -#
  23      -#
  24      -# Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
  25      -# Use is subject to license terms.
  26      -#
       17 +
  27   18  LOG_SETUP=0
  28   19  
  29   20  ConsoleLog(){
  30   21    exec 4>/dev/console
  31   22    exec 1>>${1}
  32   23    exec 2>>${1}
  33   24    INSTALL_LOG=${1}
  34   25    LOG_SETUP=1
  35   26  }
  36   27  CopyInstallLog(){
↓ open down ↓ 56 lines elided ↑ open up ↑
  93   84    while [[ -z $(/sbin/dhcpinfo BootSrvA) ]]; do
  94   85      log "Waiting for dhcpinfo..."
  95   86      sleep 1
  96   87    done
  97   88    BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
  98   89    log "Next server: $BOOTSRVA"
  99   90    sleep 1
 100   91  }
 101   92  
 102   93  BuildBE() {
 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
       94 +  RPOOL=${1:-rpool}
       95 +  if [[ -z $2 ]]; then
       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;"`
      100 +      DECOMP="bzip2 -dc"
      101 +      GRAB="curl -s"
      102 +  else
      103 +      # ASSUME $2 is a file path.  TODO: Parse the URL...
      104 +      MEDIA=$2
      105 +      # TODO: make switch statement based on $MEDIA's extension.
      106 +      # e.g. "bz2" ==> "bzip -dc", "7z" ==> 
      107 +      DECOMP="bzip2 -dc"
      108 +      GRAB=cat
      109 +  fi
      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
 111  114    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 +  $GRAB $MEDIA | pv -B 128m -w 78 | $DECOMP | zfs receive -u $RPOOL/ROOT/omnios
      116 +  zfs set canmount=noauto $RPOOL/ROOT/omnios
      117 +  zfs set mountpoint=legacy $RPOOL/ROOT/omnios
 115  118    log "Cleaning up boot environment"
 116  119    beadm mount omnios /mnt
 117  120    ALTROOT=/mnt
 118  121    cp $ALTROOT/lib/svc/seed/global.db $ALTROOT/etc/svc/repository.db
 119  122    chmod 0600 $ALTROOT/etc/svc/repository.db
 120  123    chown root:sys $ALTROOT/etc/svc/repository.db
 121  124    /usr/sbin/devfsadm -r /mnt
 122  125    [[ -L $ALTROOT/dev/msglog ]] || \
 123  126      ln -s ../devices/pseudo/sysmsg@0:msglog $ALTROOT/dev/msglog
 124  127    MakeSwapDump
 125      -  zfs destroy rpool/ROOT/omnios@kayak
      128 +  zfs destroy $RPOOL/ROOT/omnios@kayak
 126  129  }
 127  130  
 128  131  FetchConfig(){
 129  132    ETHER=`Ether`
 130  133    BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
 131  134    CONFIG=`getvar install_config`
 132  135    CONFIG=`echo $CONFIG | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
 133  136    CONFIG=`echo $CONFIG | sed -e "s%///%//$BOOTSRVA/%g;"`
 134  137    L=${#ETHER}
 135  138    while [[ "$L" -gt "0" ]]; do
↓ open down ↓ 6 lines elided ↑ open up ↑
 142  145          return 0
 143  146        fi
 144  147        rm -f $ICFILE
 145  148      fi
 146  149      L=$(($L - 1))
 147  150    done
 148  151    return 1
 149  152  }
 150  153  
 151  154  MakeBootable(){
      155 +  RPOOL=${1:-rpool}
 152  156    log "Making boot environment bootable"
 153      -  zpool set bootfs=rpool/ROOT/omnios rpool
      157 +  zpool set bootfs=$RPOOL/ROOT/omnios rpool
 154  158    # Must do beadm activate first on the off chance we're bootstrapping from
 155  159    # GRUB.
 156      -  beadm activate omnios
      160 +  beadm activate omnios || return 1
 157  161  
      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
      168 +  fi
      169 +
 158  170    # NOTE:  This installboot loop assumes we're doing GPT whole-disk rpools.
 159  171    for i in `cat /tmp/kayak-disk-list`
 160  172    do
 161      -    installboot -mf /boot/pmbr /boot/gptzfsboot /dev/rdsk/${i}s0
      173 +      installboot -mfF /boot/pmbr /boot/gptzfsboot /dev/rdsk/${i}s0 || return 1
 162  174    done
 163  175  
 164      -  bootadm update-archive -R $ALTROOT
      176 +  bootadm update-archive -R $ALTROOT || return 1
 165  177    return 0
 166  178  }
 167  179  
 168  180  SetHostname()
 169  181  {
 170  182    log "Setting hostname: ${1}"
 171  183    /bin/hostname "$1"
 172  184    echo "$1" > $ALTROOT/etc/nodename
 173  185    head -n 26 $ALTROOT/etc/hosts > /tmp/hosts
 174  186    echo "::1\t\t$1" >> /tmp/hosts
↓ open down ↓ 11 lines elided ↑ open up ↑
 186  198    [ "$suffix" == "-" ] && suffix= || suffix=-$suffix
 187  199    SetHostname $macadr$suffix
 188  200  }
 189  201  
 190  202  SetTimezone()
 191  203  {
 192  204    log "Setting timezone: ${1}"
 193  205    sed -i -e "s:^TZ=.*:TZ=${1}:" $ALTROOT/etc/default/init
 194  206  }
 195  207  
      208 +SetLang()
      209 +{
      210 +  log "Setting language: ${1}"
      211 +  sed -i -e "s:^LANG=.*:LANG=${1}:" $ALTROOT/etc/default/init
      212 +}
      213 +
      214 +SetKeyboardLayout()
      215 +{
      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).
      219 +      layout=$1
      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
      227 +}
      228 +
 196  229  ApplyChanges(){
 197  230    SetRootPW
 198  231    [[ -L $ALTROOT/etc/svc/profile/generic.xml ]] || \
 199  232      ln -s generic_limited_net.xml $ALTROOT/etc/svc/profile/generic.xml
 200  233    [[ -L $ALTROOT/etc/svc/profile/name_service.xml ]] || \
 201  234      ln -s ns_dns.xml $ALTROOT/etc/svc/profile/name_service.xml
      235 +
      236 +  # Extras from interactive ISO/USB install...
      237 +  # arg1 == hostname
      238 +  if [[ ! -z $1 ]]; then
      239 +      SetHostname $1
      240 +  fi
      241 +
      242 +  # arg2 == timezone
      243 +  if [[ ! -z $2 ]]; then
      244 +      SetTimezone $2
      245 +  fi
      246 +
      247 +  # arg3 == Language
      248 +  if [[ ! -z $3 ]]; then
      249 +      SetLang $3
      250 +  fi
      251 +
      252 +  # arg4 == Keyboard layout
      253 +  if [[ ! -z $4 ]]; then
      254 +      SetKeyboardLayout $4
      255 +  fi
      256 +
 202  257    return 0
 203  258  }
 204  259  
 205  260  Postboot() {
 206  261    [[ -f $ALTROOT/.initialboot ]] || touch $ALTROOT/.initialboot
 207  262    echo "$*" >> $ALTROOT/.initialboot
 208  263  }
 209  264  
 210  265  Reboot() {
 211  266    # This is an awful hack... we already setup bootadm
 212  267    # and we've likely deleted enough of the userspace that this
 213  268    # can't run successfully... The easiest way to skip it is to
 214  269    # remove the binary
 215  270    rm -f /sbin/bootadm
 216  271    svccfg -s "system/boot-config:default" setprop config/fastreboot_default=false
 217  272    svcadm refresh svc:/system/boot-config:default
 218  273    reboot
 219  274  }
 220  275  
 221  276  RunInstall(){
 222      -  FetchConfig || bomb "Could not fecth kayak config for target"
      277 +  FetchConfig || bomb "Could not fetch kayak config for target"
      278 +  # Set RPOOL if it wasn't done so already. We need it set.
      279 +  RPOOL=${RPOOL:-rpool}
 223  280    . $ICFILE
 224  281    Postboot 'exit $SMF_EXIT_OK'
 225  282    ApplyChanges || bomb "Could not apply all configuration changes"
 226  283    MakeBootable || bomb "Could not make new BE bootable"
 227  284    log "Install complete"
 228  285    return 0
 229  286  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX