--- old/.gitignore	Thu Mar 23 16:21:38 2017
+++ new/.gitignore	Thu Mar 23 16:21:38 2017
@@ -1,1 +1,2 @@
 kayak_root/
+takeover-console
--- old/Makefile	Thu Mar 23 16:21:38 2017
+++ new/Makefile	Thu Mar 23 16:21:38 2017
@@ -1,28 +1,17 @@
 #
-# CDDL HEADER START
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
 #
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
 #
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
+
 #
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
+# Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
 #
-# CDDL HEADER END
-#
-#
-# Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
 
 VERSION?=$(shell awk '$$1 == "OmniOS" { print $$3 }' /etc/release)
 BUILDSEND=rpool/kayak_image
@@ -35,12 +24,15 @@
 INSTALLS=anon.dtrace.conf anon.system build_image.sh build_zfs_send.sh \
 	data/access.log data/boot data/etc data/filelist.ramdisk data/kernel \
 	data/known_extras data/mdb data/platform disk_help.sh install_help.sh \
-	install_image.sh Makefile net_help.sh README.md \
+	install_image.sh takeover-console.c Makefile net_help.sh README.md \
 	sample/000000000000.sample sample/menu.lst.000000000000
 
 TFTP_FILES=$(DESTDIR)/tftpboot/boot/platform/i86pc/kernel/amd64/unix \
 	$(DESTDIR)/tftpboot/kayak/miniroot.gz \
+	$(DESTDIR)/tftpboot/kayak/miniroot.gz.hash \
 	$(DESTDIR)/tftpboot/boot/grub/menu.lst \
+	$(DESTDIR)/tftpboot/pxeboot $(DESTDIR)/tftpboot/boot/loader.conf.local \
+	$(DESTDIR)/tftpboot/boot/forth $(DESTDIR)/tftpboot/boot/defaults \
 	$(DESTDIR)/tftpboot/pxegrub
 
 WEB_FILES=$(DESTDIR)/var/kayak/kayak/$(VERSION).zfs.bz2
@@ -61,6 +53,18 @@
 $(DESTDIR)/tftpboot/pxegrub:	/boot/grub/pxegrub
 	cp -p $< $@
 
+$(DESTDIR)/tftpboot/pxeboot:	/boot/pxeboot
+	cp -p $< $@
+
+$(DESTDIR)/tftpboot/boot/loader.conf.local:	loader.conf.local
+	cp -p $< $@
+
+$(DESTDIR)/tftpboot/boot/forth:	/boot/forth
+	cp -rp $< $@
+
+$(DESTDIR)/tftpboot/boot/defaults:	/boot/defaults
+	cp -rp $< $@
+
 $(DESTDIR)/tftpboot/boot/grub/menu.lst:	sample/menu.lst.000000000000
 	sed -e 's/@VERSION@/$(VERSION)/' $< > $@
 
@@ -70,6 +74,9 @@
 $(DESTDIR)/tftpboot/kayak/miniroot.gz:	$(BUILDSEND_MP)/miniroot.gz
 	cp -p $< $@
 
+$(DESTDIR)/tftpboot/kayak/miniroot.gz.hash:	$(BUILDSEND_MP)/miniroot.gz
+	digest -a sha1 $< > $@
+
 build_image.sh:
 	VERSION=$(VERSION) ./build_image.sh
 
@@ -116,3 +123,12 @@
 install-tftp:	tftp-dirs $(TFTP_FILES)
 
 install-web:	server-dirs $(WEB_FILES)
+
+takeover-console:	takeover-console.c
+	gcc -o takeover-console takeover-console.c
+
+install-iso:	takeover-console install-tftp install-web
+	BUILDSEND_MP=$(BUILDSEND_MP) VERSION=$(VERSION) ./build_iso.sh
+
+install-usb:	install-iso
+	./usbgen.sh $(BUILDSEND_MP)/$(VERSION).iso $(BUILDSEND_MP)/$(VERSION).usb-dd /tmp
--- old/README.md	Thu Mar 23 16:21:38 2017
+++ new/README.md	Thu Mar 23 16:21:38 2017
@@ -17,11 +17,11 @@
 DHCP server:
  * your server should be set to PXE boot
  * the DHCP server must return and IP, a nextserver and a bootfile
- * the boot file should be the file {{{/boot/grub/pxegrub}}} from an existing OmniOS system
+ * the boot file should be the file {{{/boot/grub/pxegrub}}} or {{{/boot/pxeboot}}} from an existing OmniOS system
 
 TFTP server:
- * menu.lst.01<macaddr_just_hex_caps> based on the template provided in this directory should be placed in /tftpboot/
- * /boot/grub/pxegrub should be placed in /tftpboot/
+ * menu.lst.01<macaddr_just_hex_caps> based on the template provided in this directory should be placed in /tftpboot/ if using grub, or put loader.conf.local in /tftpboot/boot
+ * /boot/grub/pxegrub or /boot/pxeboot should be placed in /tftpboot/
  * /platform/i86pc/kernel/amd64/unix should be placed in /tftpboot/omnios/kayak/
  * the miniroot.gz file should be placed in /tftpboot/omnios/kayak/
 
--- old/build_image.sh	Thu Mar 23 16:21:38 2017
+++ new/build_image.sh	Thu Mar 23 16:21:38 2017
@@ -1,29 +1,20 @@
 #!/bin/bash
+
 #
-# CDDL HEADER START
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
 #
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
 #
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
+
 #
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
+# Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
 #
-# CDDL HEADER END
-#
-#
-# Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
+
 fail() {
 	echo "ERROR: $*"
 	exit 1
@@ -56,7 +47,6 @@
 fi
 SVCCFG_DTD=${ROOTDIR}/usr/share/lib/xml/dtd/service_bundle.dtd.1
 SVCCFG_REPOSITORY=${ROOTDIR}/etc/svc/repository.db
-#SVCCFG=/usr/sbin/svccfg
 if [[ -f ${PREBUILT_ILLUMOS}/usr/src/cmd/svc/svccfg/svccfg-native ]]; then
 	SVCCFG=${PREBUILT_ILLUMOS}/usr/src/cmd/svc/svccfg/svccfg-native
 else
@@ -118,7 +108,7 @@
 	system/stmf.xml system/fmd.xml system/utmp.xml
 	system/poold.xml system/dumpadm.xml"
 
-SYSTEM="system/boot/grub system/boot/real-mode system/boot/wanboot/internal
+SYSTEM="system/boot/real-mode system/boot/wanboot/internal
 	system/boot/loader system/boot/wanboot system/data/hardware-registry
 	system/data/keyboard/keytables system/data/terminfo
 	system/data/zoneinfo system/extended-system-utilities
@@ -164,7 +154,7 @@
 	driver/network/rge driver/network/rpcib driver/network/rtls
 	driver/network/sdp driver/network/sdpib driver/network/sfe
 	driver/network/tavor driver/network/usbecm driver/network/vr
-	driver/network/xge driver/network/yge driver/pcmcia driver/serial/pcser
+	driver/network/xge driver/network/yge driver/pcmcia
 	driver/serial/usbftdi driver/serial/usbsacm driver/serial/usbser
 	driver/serial/usbser_edge driver/serial/usbsksp
 	driver/serial/usbsksp/usbs49_fw driver/serial/usbsprl
@@ -173,7 +163,7 @@
 	driver/storage/bcm_sata driver/storage/blkdev driver/storage/cpqary3
 	driver/storage/glm driver/storage/lsimega driver/storage/marvell88sx
 	driver/storage/mega_sas driver/storage/mpt_sas driver/storage/mr_sas
-	driver/storage/nv_sata driver/storage/pcata driver/storage/pmcs
+	driver/storage/nv_sata driver/storage/pmcs
 	driver/storage/sbp2 driver/storage/scsa1394 driver/storage/sdcard
 	driver/storage/ses driver/storage/si3124 driver/storage/smp
 	driver/usb driver/usb/ugen driver/xvm/pv driver/storage/vioblk
@@ -180,7 +170,7 @@
 	driver/network/vioif driver/storage/nvme driver/storage/pvscsi"
 
 PARTS="release/name release/notices service/picl install/beadm SUNWcs SUNWcsd
-	library/libidn shell/pipe-viewer text/less editor/vim
+	library/libidn shell/pipe-viewer text/less editor/vim web/curl
         developer/linker file/gnu-coreutils openssh openssh-server
 	diagnostic/diskinfo"
 
@@ -350,6 +340,11 @@
 	mkdir $WORKDIR/mnt/kayak
 	cp $SRCDIR/*.sh $WORKDIR/mnt/kayak/
 	chmod a+x $WORKDIR/mnt/kayak/*.sh
+
+	# So "bootadm update-archive" can work.
+	cp $SRCDIR/digest $WORKDIR/mnt/usr/bin/digest
+	chmod 0755 $WORKDIR/mnt/usr/bin/digest
+
 	make_initial_boot $WORKDIR/mnt/.initialboot
 	if [[ -n "$DEBUG" ]]; then
 		cp $SRCDIR/anon.system $WORKDIR/mnt/etc/system
--- /dev/null	Thu Mar 23 16:21:38 2017
+++ new/build_iso.sh	Thu Mar 23 16:21:38 2017
@@ -0,0 +1,153 @@
+#!/usr/bin/bash
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
+#
+
+#
+# Build an ISO installer using the Kayak tools.
+#
+
+if [[ `id -u` != "0" ]]; then
+	echo "You must be root to run this script."
+	exit 1
+fi
+
+if [[ -z $BUILDSEND_MP ]]; then
+	echo "Using /rpool/kayak_image for BUILDSEND_MP"
+	BUILDSEND_MP=/rpool/kayak_image
+fi
+
+if [[ -z $VERSION ]]; then
+	VERSION=`grep OmniOS $BUILDSEND_MP/root/etc/release | awk '{print $3}'`
+	echo "Using $VERSION..."
+fi
+
+# Many of these depend on sufficient space in /tmp by default.  Please
+# modify as you deem appropriate.
+PROTO=/tmp/proto
+KAYAK_ROOTBALL=$BUILDSEND_MP/miniroot.gz
+KAYAK_ROOT=/tmp/miniroot.$$
+KR_FILE=/tmp/kr.$$
+MNT=/mnt
+UFS_LOFI=/tmp/boot_archive
+LOFI_SIZE=600M
+DST_ISO=$BUILDSEND_MP/${VERSION}.iso
+ZFS_IMG=$BUILDSEND_MP/kayak_${VERSION}.zfs.bz2
+
+# Create a UFS lofi file and mount the UFS filesystem in $MNT.  This will
+# form the boot_archive for the ISO.
+mkfile $LOFI_SIZE $UFS_LOFI
+LOFI_PATH=`lofiadm -a $UFS_LOFI`
+echo 'y' | newfs $LOFI_PATH
+mount $LOFI_PATH $MNT
+
+# Clone the already-created Kayak miniroot and copy it into both $MNT, and
+# into a now-created $PROTO. $PROTO will form the directory that gets
+# sprayed onto the ISO.
+gunzip -c $KAYAK_ROOTBALL > $KR_FILE
+LOFI_RPATH=`lofiadm -a $KR_FILE`
+mkdir $KAYAK_ROOT
+mount $LOFI_RPATH $KAYAK_ROOT
+tar -cf - -C $KAYAK_ROOT . | tar -xf - -C $MNT
+mkdir $PROTO
+tar -cf - -C $KAYAK_ROOT . | tar -xf - -C $PROTO
+umount $KAYAK_ROOT
+rmdir $KAYAK_ROOT
+lofiadm -d $LOFI_RPATH
+rm $KR_FILE
+
+#
+# Put additional goodies into the boot-archive on $MNT, which is
+# what'll be / (via ramdisk) once one boots the ISO.
+# 
+
+# The full ZFS image (also already-created) for actual installation.
+cp $ZFS_IMG $MNT/root/.
+
+# A cheesy way to get the boot menu to appear at boot time.
+cp -p ./takeover-console $MNT/kayak/.
+cat <<EOF > $MNT/root/.bashrc
+export PATH=/usr/bin:/usr/sbin:/sbin
+export HOME=/root
+EOF
+# Have initialboot muck with the console login service to make an interactive
+# installer get invoked.
+cat <<EOF > $MNT/.initialboot
+/usr/sbin/svccfg -s console-login:default setprop startd/need_session = boolean: true
+/usr/sbin/svcadm refresh console-login:default
+/usr/sbin/svcadm restart console-login:default
+EOF
+cat <<EOF > $MNT/lib/svc/method/console-login
+#!/bin/bash
+
+# CHEESY way to get the kayak-menu running w/o interference.
+export TERM=sun-color
+/kayak/takeover-console /kayak/kayak-menu.sh
+EOF
+chmod 0755 $MNT/lib/svc/method/console-login
+
+# Refresh the devices on the miniroot.
+devfsadm -r $MNT
+
+#
+# The ISO's miniroot is going to be larger than the PXE miniroot.  To that
+# end, some files not listed in the exception list do need to show up on
+# the miniroot.  Use PREBUILT_ILLUMOS if available, or the current system
+# if not.
+#
+from_one_to_other() {
+    dir=$1
+    if [[ -z $PREBUILT_ILLUMOS || ! -d $PREBUILT_ILLUMOS/proto/root_i386/$dir ]]
+    then
+	FROMDIR=/
+    else
+	FROMDIR=$PREBUILT_ILLUMOS/proto/root_i386
+    fi
+
+    shift
+    tar -cf - -C $FROMDIR/$dir ${@:-.} | tar -xf - -C $MNT/$dir
+}
+
+# Add from_one_to_other for any directory {file|subdir file|subdir ...} you need
+from_one_to_other usr/share/lib/zoneinfo
+from_one_to_other usr/share/lib/keytables
+from_one_to_other usr/share/lib/terminfo
+from_one_to_other usr/gnu/share/terminfo
+from_one_to_other usr/sbin ping
+from_one_to_other usr/bin netstat
+
+# Remind people this is the installer.
+cat <<EOF > $PROTO/boot/loader.conf.local
+loader_menu_title="Welcome to the OmniOS installer"
+autoboot_delay=5
+EOF
+
+#
+# Okay, we've populated the new ISO miniroot.  Close it up and install it
+# on $PROTO as the boot archive.
+#
+umount $MNT
+lofiadm -d $LOFI_PATH
+cp $UFS_LOFI $PROTO/platform/i86pc/amd64/boot_archive
+digest -a sha1 $UFS_LOFI > $PROTO/platform/i86pc/amd64/boot_archive.hash
+rm -rf $PROTO/{usr,bin,sbin,lib,kernel}
+du -sh $PROTO/.
+
+# And finally, burn the ISO.
+mkisofs -o $DST_ISO -b boot/cdboot -c .catalog -no-emul-boot -boot-load-size 4 -boot-info-table -N -l -R -U -allow-multidot -no-iso-translate -cache-inodes -d -D -V OmniOS $PROTO
+
+rm -rf $PROTO $UFS_LOFI
+echo "$DST_ISO is ready"
+ls -lt $DST_ISO
--- old/data/access.log	Thu Mar 23 16:21:38 2017
+++ new/data/access.log	Thu Mar 23 16:21:38 2017
@@ -203,6 +203,7 @@
 20502313 /kernel/drv/amd64/sysmsg
 20502320 /var/run
 20502325 /lib/libnvpair.so.1
+20502325 /lib/amd64/libnvpair.so.1
 20502328 /dev/console
 20502329 /kernel/drv/amd64/cn
 20502335 /lib/libnsl.so.1
@@ -1152,7 +1153,7 @@
 20567974 /usr/lib/amd64/libidn.so.11.6.15
 20567979 /usr/lib/amd64/libssl.so.1.0.0
 20567979 /usr/lib/amd64/libnghttp2.so.14
-20567979 /usr/lib/amd64/libnghttp2.so.14.11.0
+20567979 /usr/lib/amd64/libnghttp2.so.14.12.4
 20567979 /lib/amd64/libssl.so.1.0.0
 20567983 /usr/lib/amd64/libcrypto.so.1.0.0
 20567983 /lib/amd64/libcrypto.so.1.0.0
--- old/data/known_extras	Thu Mar 23 16:21:38 2017
+++ new/data/known_extras	Thu Mar 23 16:21:38 2017
@@ -43,6 +43,11 @@
 0 /lib/libcrypto.so.1.0.0
 0 /usr/bin/ssh
 0 /usr/bin/scp
+0 /usr/bin/clear
+0 /usr/bin/tput
+0 /usr/bin/getent
+0 /usr/bin/kbd
+0 /usr/bin/loadkeys
 0 /usr/bin/mkfifo
 0 /usr/bin/dd
 0 /usr/bin/i86/ps
--- /dev/null	Thu Mar 23 16:21:38 2017
+++ new/digest	Thu Mar 23 16:21:38 2017
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
+#
+
+# Gross hack to create a version of /usr/bin/digest that doesn't need
+# to have all of the crypto framework libraries. sha1sum is available,
+# and we can use it.  This is needed for bootadm(1M).
+
+# FOR NOW, assume we're only ever going to be invoked by create_ramdisk,
+# which uses "digest -a sha1 <one-filename>".
+
+usage() {
+    echo "Usage:" > /dev/stderr
+    echo "  digest -l | [-v] -a <algorithm> [file...]" > /dev/stderr
+    exit 2
+}
+
+if [[ $1 != "-a" || $2 != "sha1" ]]; then
+    usage
+fi
+
+sha1sum $3 | awk '{print $1}'
+exit 0
--- old/disk_help.sh	Thu Mar 23 16:21:38 2017
+++ new/disk_help.sh	Thu Mar 23 16:21:38 2017
@@ -1,29 +1,20 @@
 #!/usr/bin/bash
+
 #
-# CDDL HEADER START
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
 #
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
 #
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
+
 #
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
+# Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
 #
-# CDDL HEADER END
-#
-#
-# Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
+
 ListDisks() {
   declare -A disksize
   declare -A diskname
@@ -92,13 +83,13 @@
   done | sort | uniq | xargs
 }
 
-BuildRpool() {
+BuildRpoolOnly() {
   ztype=""
   ztgt=""
   disks=`ListDisksUnique $*`
-  log "Disks being used for rpool: $disks"
+  log "Disks being used for root pool $RPOOL: $disks"
   if [[ -z "$disks" ]]; then
-    bomb "No matching disks found to build rpool"
+    bomb "No matching disks found to build root pool $RPOOL"
   fi
   rm -f /tmp/kayak-disk-list
   for i in $disks
@@ -110,11 +101,14 @@
     # Keep track of disks for later...
     echo ${i} >> /tmp/kayak-disk-list
   done
-  log "zpool destroy rpool (just in case we've been run twice)"
-  zpool destroy rpool 2> /dev/null
-  log "Creating rpool with: zpool create -f rpool $ztype $ztgt"
+  log "zpool destroy $RPOOL (just in case we've been run twice)"
+  zpool destroy $RPOOL 2> /dev/null
+  log "Creating root pool with: zpool create -f $RPOOL $ztype $ztgt"
   # Just let "zpool create" do its thing. We want GPT disks now.
-  zpool create -f rpool $ztype $ztgt || bomb "Failed to create rpool"
+  zpool create -f $RPOOL $ztype $ztgt || bomb "Failed to create root pool $RPOOL"
+}
+BuildRpool() {
+  BuildRpoolOnly $*
   BuildBE
 }
 GetTargetVolSize() {
@@ -130,7 +124,7 @@
     echo $vsize
 }    
 GetRpoolFree() {
-    local zfsavail=`/sbin/zfs list -H -o avail rpool`
+    local zfsavail=`/sbin/zfs list -H -o avail $RPOOL` 
     if [[ ${zfsavail:(-1)} = "G" ]]; then
         local avail=`printf %0.f ${zfsavail::-1}`
     elif [[ ${zfsavail:(-1)} = "T" ]]; then
@@ -171,10 +165,10 @@
     fi
 
     for volname in swap dump; do
-        /sbin/zfs create -V ${finalsize}G rpool/$volname || \
-            bomb "Failed to create rpool/$volname"
+        /sbin/zfs create -V ${finalsize}G $RPOOL/$volname || \
+            bomb "Failed to create $RPOOL/$volname"
     done
-    printf "/dev/zvol/dsk/rpool/swap\t-\t-\tswap\t-\tno\t-\n" >> $ALTROOT/etc/vfstab
-    Postboot /usr/sbin/dumpadm $savecore -d /dev/zvol/dsk/rpool/dump
+    printf "/dev/zvol/dsk/$RPOOL/swap\t-\t-\tswap\t-\tno\t-\n" >> $ALTROOT/etc/vfstab
+    Postboot /usr/sbin/dumpadm $savecore -d /dev/zvol/dsk/$RPOOL/dump
     return 0
 }
--- /dev/null	Thu Mar 23 16:21:39 2017
+++ new/find-and-install.sh	Thu Mar 23 16:21:39 2017
@@ -0,0 +1,129 @@
+#!/usr/bin/bash
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
+#
+
+# Capture diskinfo(1M) output in a tempfile.
+
+keyboard_layout=${1:-US-English}
+SCRATCH=/tmp/di.$$
+diskinfo > $SCRATCH
+numdisks=`wc -l $SCRATCH | awk '{print $1}'`
+echo "numdisks before $numdisks"
+numdisks=$(($numdisks - 1))
+echo "numdisks after $numdisks"
+
+# Number of disks on one page, must be <= 7.
+onepage=7
+highpage=$(($numdisks / $onepage))
+remainder=$(($numdisks % $onepage))
+if [[ $remainder != 0 ]]; then
+    highpage=$(($highpage + 1))
+fi
+
+# Present the list of disks in a pretty manner, and get the user to
+# generate a list of one or more disks.  Put them in $DISKLIST...
+finished=0
+offset=2
+page=0
+DISKLIST=""
+until [[ $finished == 1 ]]; do
+    clear
+    echo "root pool disks: [$DISKLIST]"
+    echo "0 == done, 1-7 == select-disk 8 == next-page, 9 == clear"
+    echo "--------------------------------------------------------"
+    head -1 $SCRATCH | awk '{print "#   ",$0}'
+    echo ""
+    tail +$offset $SCRATCH | head -$onepage | awk '{print NR,"   ",$0}' \
+						  > /tmp/dp.$$
+    cat /tmp/dp.$$
+    echo ""
+    echo -n "Enter a digit or the disk device name ==> "
+    read choice
+
+    if [[ $choice == 9 ]]; then
+	DISKLIST=""
+    elif [[ $choice == 8 ]]; then
+	page=$(($page + 1))
+	if [[ $page == $highpage ]]; then
+	    page=0
+	fi
+	offset=$(($page * $onepage + 2))
+    elif [[ $choice == 0 ]]; then
+	if [[ $DISKLIST == "" ]]; then
+	    echo -n "Press RETURN to go back to the main menu: "
+	    read
+	    exit
+	else
+	    finished=1
+	fi
+    else
+	if [[ $choice == "" ]]; then
+	    continue
+	fi
+	NEWDISK=`nawk -v choice=$choice '$1 == choice {print $3}' < /tmp/dp.$$`
+	if [[ $NEWDISK == "" ]]; then
+	    NEWDISK=`nawk -v choice=$choice '$3 == choice {print $3}' < \
+		/tmp/dp.$$`
+	fi
+	if [[ $NEWDISK != "" ]]; then
+	    if [[ $DISKLIST == "" ]]; then
+		DISKLIST=$NEWDISK
+	    elif [[ `echo $DISKLIST | grep $NEWDISK` == "" ]]; then
+		DISKLIST="$DISKLIST $NEWDISK"
+	    fi
+	fi
+    fi
+    rm /tmp/dp.$$
+done
+
+
+reality_check() {
+    mkfile 64m /tmp/test.$$
+    if [[ $? != 0 ]]; then
+	echo "WARNING: Insufficient space in /tmp for installation..."
+	return 1
+    fi
+    zpool create $1 /tmp/test.$$
+    if [[ $? != 0 ]]; then
+	echo "Can't test zpool create $1"
+	return 1
+    fi
+    zpool destroy $1
+    rm -f /tmp/test.$$
+    return 0
+}
+
+NEWRPOOL="rpool"
+until [[ $NEWRPOOL == "" ]]; do
+    RPOOL=$NEWRPOOL
+    echo -n "Enter the root pool name or press RETURN if you want [$RPOOL]: "
+    read NEWRPOOL
+    if [[ $NEWRPOOL != "" ]]; then
+	reality_check $NEWRPOOL
+	if [[ $? != 0 ]]; then
+	    NEWRPOOL=$RPOOL
+	fi
+    fi
+done
+
+. /kayak/install_help.sh
+. /kayak/disk_help.sh
+BuildRpoolOnly $DISKLIST
+
+rm -f $SCRATCH
+
+# Running actual install.
+/kayak/rpool-install.sh $RPOOL $keyboard_layout
--- old/install_help.sh	Thu Mar 23 16:21:39 2017
+++ new/install_help.sh	Thu Mar 23 16:21:39 2017
@@ -1,29 +1,20 @@
 #!/usr/bin/bash
+
 #
-# CDDL HEADER START
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
 #
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
 #
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
+
 #
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
+# Copyright 2017 OmniTI Computer Consulting, Inc.  All rights reserved.
 #
-# CDDL HEADER END
-#
-#
-# Copyright 2012 OmniTI Computer Consulting, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
+
 LOG_SETUP=0
 
 ConsoleLog(){
@@ -100,18 +91,30 @@
 }
 
 BuildBE() {
-  BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
-  MEDIA=`getvar install_media`
-  MEDIA=`echo $MEDIA | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
-  MEDIA=`echo $MEDIA | sed -e "s%///%//$BOOTSRVA/%g;"`
-  zfs set compression=on rpool
-  zfs create rpool/ROOT
-  zfs set canmount=off rpool/ROOT
-  zfs set mountpoint=legacy rpool/ROOT
+  RPOOL=${1:-rpool}
+  if [[ -z $2 ]]; then
+      BOOTSRVA=`/sbin/dhcpinfo BootSrvA`
+      MEDIA=`getvar install_media`
+      MEDIA=`echo $MEDIA | sed -e "s%//\:%//$BOOTSRVA\:%g;"`
+      MEDIA=`echo $MEDIA | sed -e "s%///%//$BOOTSRVA/%g;"`
+      DECOMP="bzip2 -dc"
+      GRAB="curl -s"
+  else
+      # ASSUME $2 is a file path.  TODO: Parse the URL...
+      MEDIA=$2
+      # TODO: make switch statement based on $MEDIA's extension.
+      # e.g. "bz2" ==> "bzip -dc", "7z" ==> 
+      DECOMP="bzip2 -dc"
+      GRAB=cat
+  fi
+  zfs set compression=on $RPOOL
+  zfs create $RPOOL/ROOT
+  zfs set canmount=off $RPOOL/ROOT
+  zfs set mountpoint=legacy $RPOOL/ROOT
   log "Receiving image: $MEDIA"
-  curl -s $MEDIA | pv -B 128m | bzip2 -dc | zfs receive -u rpool/ROOT/omnios
-  zfs set canmount=noauto rpool/ROOT/omnios
-  zfs set mountpoint=legacy rpool/ROOT/omnios
+  $GRAB $MEDIA | pv -B 128m -w 78 | $DECOMP | zfs receive -u $RPOOL/ROOT/omnios
+  zfs set canmount=noauto $RPOOL/ROOT/omnios
+  zfs set mountpoint=legacy $RPOOL/ROOT/omnios
   log "Cleaning up boot environment"
   beadm mount omnios /mnt
   ALTROOT=/mnt
@@ -122,7 +125,7 @@
   [[ -L $ALTROOT/dev/msglog ]] || \
     ln -s ../devices/pseudo/sysmsg@0:msglog $ALTROOT/dev/msglog
   MakeSwapDump
-  zfs destroy rpool/ROOT/omnios@kayak
+  zfs destroy $RPOOL/ROOT/omnios@kayak
 }
 
 FetchConfig(){
@@ -149,19 +152,28 @@
 }
 
 MakeBootable(){
+  RPOOL=${1:-rpool}
   log "Making boot environment bootable"
-  zpool set bootfs=rpool/ROOT/omnios rpool
+  zpool set bootfs=$RPOOL/ROOT/omnios rpool
   # Must do beadm activate first on the off chance we're bootstrapping from
   # GRUB.
-  beadm activate omnios
+  beadm activate omnios || return 1
 
+  if [[ ! -z $1 ]]; then
+      # Generate kayak-disk-list from zpool status.
+      # NOTE: If this is something on non-s0 slices, the installboot below
+      # will fail most likely, which is possibly a desired result.
+      zpool list -v $RPOOL | egrep -v "NAME|rpool|mirror" | \
+	  awk '{print $1}' | sed -E 's/s0$//g' > /tmp/kayak-disk-list
+  fi
+
   # NOTE:  This installboot loop assumes we're doing GPT whole-disk rpools.
   for i in `cat /tmp/kayak-disk-list`
   do
-    installboot -mf /boot/pmbr /boot/gptzfsboot /dev/rdsk/${i}s0
+      installboot -mfF /boot/pmbr /boot/gptzfsboot /dev/rdsk/${i}s0 || return 1
   done
 
-  bootadm update-archive -R $ALTROOT
+  bootadm update-archive -R $ALTROOT || return 1
   return 0
 }
 
@@ -193,6 +205,27 @@
   sed -i -e "s:^TZ=.*:TZ=${1}:" $ALTROOT/etc/default/init
 }
 
+SetLang()
+{
+  log "Setting language: ${1}"
+  sed -i -e "s:^LANG=.*:LANG=${1}:" $ALTROOT/etc/default/init
+}
+
+SetKeyboardLayout()
+{
+      # Put the new keyboard layout ($1) in
+      # "setprop keyboard-layout <foo>" in the newly-installed root's
+      # /boot/solaris/bootenv.rc (aka. eeprom(1M) storage for amd64/i386).
+      layout=$1
+      sed "s/keyboard-layout Unknown/keyboard-layout $layout/g" \
+	  < $ALTROOT/boot/solaris/bootenv.rc > /tmp/bootenv.rc
+      mv /tmp/bootenv.rc $ALTROOT/boot/solaris/bootenv.rc
+      # Also modify the SMF manifest, assuming US-English was set by default.
+      sed "s/US-English/$layout/g" \
+	 < $ALTROOT/lib/svc/manifest/system/keymap.xml > /tmp/keymap.xml
+      cp -f /tmp/keymap.xml $ALTROOT/lib/svc/manifest/system/keymap.xml
+}
+
 ApplyChanges(){
   SetRootPW
   [[ -L $ALTROOT/etc/svc/profile/generic.xml ]] || \
@@ -199,6 +232,28 @@
     ln -s generic_limited_net.xml $ALTROOT/etc/svc/profile/generic.xml
   [[ -L $ALTROOT/etc/svc/profile/name_service.xml ]] || \
     ln -s ns_dns.xml $ALTROOT/etc/svc/profile/name_service.xml
+
+  # Extras from interactive ISO/USB install...
+  # arg1 == hostname
+  if [[ ! -z $1 ]]; then
+      SetHostname $1
+  fi
+
+  # arg2 == timezone
+  if [[ ! -z $2 ]]; then
+      SetTimezone $2
+  fi
+
+  # arg3 == Language
+  if [[ ! -z $3 ]]; then
+      SetLang $3
+  fi
+
+  # arg4 == Keyboard layout
+  if [[ ! -z $4 ]]; then
+      SetKeyboardLayout $4
+  fi
+
   return 0
 }
 
@@ -219,7 +274,9 @@
 }
 
 RunInstall(){
-  FetchConfig || bomb "Could not fecth kayak config for target"
+  FetchConfig || bomb "Could not fetch kayak config for target"
+  # Set RPOOL if it wasn't done so already. We need it set.
+  RPOOL=${RPOOL:-rpool}
   . $ICFILE
   Postboot 'exit $SMF_EXIT_OK'
   ApplyChanges || bomb "Could not apply all configuration changes"
--- /dev/null	Thu Mar 23 16:21:39 2017
+++ new/kayak-menu.sh	Thu Mar 23 16:21:39 2017
@@ -0,0 +1,207 @@
+#!/bin/ksh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
+#
+
+# This started its life as the Caiman text-installer menu, hence the old
+# OpenSolaris CDDL statement.
+
+# LOGNAME variable is needed to display the shell prompt appropriately
+export LOGNAME=root
+
+# Block all signals which could terminate the menu or return to a parent process
+trap "" TSTP INT TERM ABRT QUIT
+
+# Determine which shell program to use by grabbing this user's login-shell
+# from /etc/passwd
+ROOT_SHELL=$(/usr/bin/getent passwd $LOGNAME |/usr/bin/cut -d':' -f7)
+
+# On the off chance that $LOGNAME has no shell (default grabbed from passwd(4)p)
+if [[ -z "$ROOT_SHELL" ]]; then
+	ROOT_SHELL="/usr/bin/sh"
+fi
+
+# Get the user's keyboard choice out of the way now.
+/usr/bin/kbd -s
+/usr/bin/loadkeys
+# Remember it post-installation scribbling into installed-image /etc/default/kbd
+ktype=`/usr/bin/kbd -l | grep type | awk -F= '{print $2}'`
+layout=`/usr/bin/kbd -l | grep layout | awk -F= '{print $2}' | awk '{print $1}'`
+klang=`grep -w $layout /usr/share/lib/keytables/type_$ktype/kbd_layouts | awk -F= '{print $1}'`
+
+# Define the menu of commands and prompts
+menu_items=( \
+    (menu_str="Find disks, create rpool, and install OmniOS"		 \
+	cmds=("/kayak/find-and-install.sh $klang")			 \
+	do_subprocess="true"						 \
+	msg_str="")							 \
+    (menu_str="Install OmniOS straight on to a preconfigured rpool"	 \
+	cmds=("/kayak/rpool-install.sh rpool $klang")			 \
+	do_subprocess="true"						 \
+	msg_str="")							 \
+    (menu_str="Shell (for manual rpool creation, or post-install ops on /mnt)" \
+	cmds=("$ROOT_SHELL")						 \
+	do_subprocess="true"						 \
+	msg_str="To return to the main menu, exit the shell")	 \
+    # this string gets overwritten every time $TERM is updated
+    (menu_str="Terminal type (currently ""$TERM)"		 \
+	cmds=("prompt_for_term_type")					 \
+	do_subprocess="false"						 \
+	msg_str="")							 \
+    (menu_str="Reboot"					 \
+	cmds=("/usr/sbin/reboot" "/usr/bin/sleep 10000")		 \
+	do_subprocess="true"						 \
+	msg_str="")							 \
+)
+
+# Update the menu_str for the terminal type
+# entry. Every time the terminal type has been
+# updated, this function must be called.
+function update_term_menu_str
+{
+    # update the menu string to reflect the current TERM
+    for i in "${!menu_items[@]}"; do
+	    if [[ "${menu_items[$i].cmds[0]}" = "prompt_for_term_type" ]] ; then
+		menu_items[$i].menu_str="Terminal type (currently $TERM)"
+	    fi
+    done
+}
+
+# Set the TERM variable as follows:
+#
+# Just set it to "sun-color" for now.
+#
+function set_term_type
+{
+    export TERM=sun-color
+    update_term_menu_str
+}
+
+# Prompt the user for terminal type
+function prompt_for_term_type
+{
+	integer i
+
+	# list of suggested termtypes
+	typeset termtypes=(
+		typeset -a fixedlist
+		integer list_len        # number of terminal types
+	)
+
+	# hard coded common terminal types
+	termtypes.fixedlist=(
+		[0]=(  name="sun-color"		desc="PC Console"           )
+		[1]=(  name="xterm"		desc="xterm"		    )
+		[2]=(  name="vt100"		desc="DEC VT100"	    )
+	)
+
+	termtypes.list_len=${#termtypes.fixedlist[@]}
+
+	# Start with a newline before presenting the choices
+	print
+	printf "Indicate the type of terminal being used, such as:\n"
+
+	# list suggested terminal types
+	for (( i=0 ; i < termtypes.list_len ; i++ )) ; do
+		nameref node=termtypes.fixedlist[$i]
+		printf "  %-10s %s\n" "${node.name}" "${node.desc}"
+	done
+
+	print
+	# Prompt user to select terminal type and check for valid entry
+	typeset term=""
+	while true ; do
+		read "term?Enter terminal type [$TERM]: " || continue
+
+		# if the user just hit return, don't set the term variable
+		[[ "${term}" = "" ]] && return
+			
+		# check if the user specified option is valid
+		term_entry=`/usr/bin/ls /usr/gnu/share/terminfo/*/$term 2> /dev/null`
+		[[ ! -z ${term_entry} ]] && break
+		print "terminal type not supported. Supported terminal types can be \n" "${term}"
+		print "found by using the Shell to list the contents of /usr/gnu/share/terminfo.\n\n"
+	done
+
+	export TERM="${term}"
+	update_term_menu_str
+}
+
+set_term_type
+
+# default to the Installer option
+defaultchoice=1
+
+for ((;;)) ; do
+
+	# Display the menu.
+	stty sane
+	clear
+	printf \
+	    "Welcome to the OmniOS installation menu"
+	print " \n\n"
+	for i in "${!menu_items[@]}"; do
+		print "\t$((${i} + 1))  ${menu_items[$i].menu_str}"
+	done
+
+	# Take an entry (by number). If multiple numbers are
+ 	# entered, accept only the first one.
+	input=""
+	dummy=""
+	print -n "\nPlease enter a number [${defaultchoice}]: "
+	read input dummy 2>/dev/null
+
+	# If no input was supplied, select the default option
+	[[ -z ${input} ]] && input=$defaultchoice
+
+	# First char must be a digit.
+	if [[ ${input} =~ [^1-9] || ${input} > ${#menu_items[@]} ]] ; then
+		continue
+	fi
+
+	# Reorient to a zero base.
+	input=$((${input} - 1))
+
+	nameref msg_str=menu_items[$input].msg_str
+
+	# Launch commands as a subprocess.
+	# However, launch the functions within the context 
+	# of the current process.
+	if [[ "${menu_items[$input].do_subprocess}" = "true" ]] ; then
+		(
+		trap - TSTP INT TERM ABRT QUIT
+		# Print out a message if requested
+		[[ ! -z "${msg_str}" ]] && printf "%s\n" "${msg_str}"
+		for j in "${!menu_items[$input].cmds[@]}"; do
+			${menu_items[${input}].cmds[$j]}
+		done
+		)
+	else
+		# Print out a message if requested
+		[[ ! -z "${msg_str}" ]] && printf "%s\n" "${msg_str}"
+		for j in "${!menu_items[$input].cmds[@]}"; do
+			${menu_items[${input}].cmds[$j]}
+		done
+	fi
+done
--- /dev/null	Thu Mar 23 16:21:39 2017
+++ new/loader.conf.local	Thu Mar 23 16:21:39 2017
@@ -0,0 +1,24 @@
+# So we can tell loader the right things for a PXE boot of Kayak...
+
+# Our unix lives under boot...
+bootfile="/boot/platform/i86pc/kernel/amd64/unix"
+
+# We need some install boot arguments...
+# NOTE: "x.y.z.a" should be filled in with an actual IP address for the "kayak"
+# service host.
+boot-args="-B install_media=http://x.y.z.a/kayak/r151021-20170314.zfs.bz2,install_config=http://x.y.z.a/kayak"
+
+# Like the ISO, let people know we're in the PXE installer:
+loader_menu_title="Welcome to the OmniOS PXE Installer"
+autoboot_delay=1
+
+# Make sure we're maxed out on TFTP block size.
+tftp.blksize="1428"
+
+# Same with NFS if we use it. Optimize for NFS-in-UDP-in-PathMTU.
+nfs.read_size="1344"
+
+# Now the boot-archive in loader is different.  We don't need a .gz in
+# the filename because loader looks for <name>.gz.
+boot_archive_name="kayak/miniroot"
+boot_archive.hash_name="kayak/miniroot.gz.hash"
--- /dev/null	Thu Mar 23 16:21:39 2017
+++ new/rpool-install.sh	Thu Mar 23 16:21:39 2017
@@ -0,0 +1,84 @@
+#!/usr/bin/bash
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
+#
+
+RPOOL=${1:-rpool}
+ZFS_IMAGE=/root/*.zfs.bz2
+keyboard_layout=${2:-US-English}
+
+zpool list $RPOOL >& /dev/null
+if [[ $? != 0 ]]; then
+   echo "Cannot find root pool $RPOOL"
+   echo "Press RETURN to exit"
+   read
+   exit 1
+fi
+
+echo "Installing from ZFS image $ZFS_IMAGE"
+
+
+. /kayak/disk_help.sh
+. /kayak/install_help.sh
+
+reality_check() {
+    # Make sure $1 (hostname) is a legit one.
+    echo $1 | egrep '^[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]$' > /dev/null
+    if [[ $? != 0 ]]; then
+        echo "[$1] is not a legitimate hostname."
+        return -1
+    fi
+    return 0
+}
+
+# Select a host name
+NEWHOST="unknown"
+until [[ $NEWHOST == "" ]]; do
+    HOSTNAME=$NEWHOST
+    echo -n "Please enter a hostname or press RETURN if you want [$HOSTNAME]: "
+    read NEWHOST
+    if [[ $NEWHOST != "" ]]; then
+	reality_check $NEWHOST
+	if [[ $? != 0 ]]; then
+	    NEWHOST=$HOSTNAME
+	fi
+    fi
+done
+
+# Select a timezone.
+NEWTZ=$TZ
+until [[ $NEWTZ == "" ]]; do
+    TZ=$NEWTZ
+    echo "Current timezone is [$TZ]:  " `TZ=$TZ date`
+    echo "(NOTE: If time/date above looks wrong, the timezone name doesn't exist.)"
+    echo -n "Enter a new timezone, or just hit RETURN to accept [$TZ]: "
+    read NEWTZ
+done
+
+# Because of kayak's small miniroot, just use C as the language for now.
+LANG=C
+
+BuildBE $RPOOL $ZFS_IMAGE
+ApplyChanges $HOSTNAME $TZ $LANG $keyboard_layout
+MakeBootable $RPOOL
+zpool list -v $RPOOL
+echo ""
+beadm list
+echo ""
+echo "$RPOOL now has a working and mounted boot environment, per above."
+echo "Once back at the main menu, you can reboot from there, or"
+echo "re-enter the shell to modify your new BE before its first boot."
+echo -n "Press RETURN to go back to the menu: "
+read
--- /dev/null	Thu Mar 23 16:21:39 2017
+++ new/takeover-console.c	Thu Mar 23 16:21:39 2017
@@ -0,0 +1,35 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
+ */
+
+#include <fcntl.h>
+#include <unistd.h>
+
+int
+main(int argc, char *argv[])
+{
+	/* Wrest control of /dev/console, and exec the commands after 0, 0. */
+	int fd;
+
+	(void) setpgrp();
+	(void) close(0);
+	(void) close(1);
+	(void) close(2);
+	fd = open("/dev/console", O_RDWR, 0);
+	if (fd == 0) {
+		(void) fcntl(0, F_DUP2FD, 1);
+		(void) fcntl(0, F_DUP2FD, 2);
+	}
+	execv(argv[1], &(argv[2]));
+}
--- /dev/null	Thu Mar 23 16:21:39 2017
+++ new/usbgen.sh	Thu Mar 23 16:21:39 2017
@@ -0,0 +1,407 @@
+#!/usr/bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Generate USB image from iso
+# Originally from slim_install, modified by Toomas Soome.
+#
+
+# Solaris needs /usr/xpg4/bin/ because the tools in /usr/bin are not
+# POSIX-conformant
+export PATH=/usr/xpg4/bin:/bin:/usr/bin:/usr/sbin
+
+# Make sure all math stuff runs in the "C" locale to avoid problems
+# with alternative # radix point representations (e.g. ',' instead of
+# '.' in de_DE.*-locales). This needs to be set _before_ any
+# floating-point constants are defined in this script).
+if [[ "${LC_ALL}" != "" ]] ; then
+    export \
+        LC_MONETARY="${LC_ALL}" \
+        LC_MESSAGES="${LC_ALL}" \
+        LC_COLLATE="${LC_ALL}" \
+        LC_CTYPE="${LC_ALL}"
+        unset LC_ALL
+fi
+export LC_NUMERIC=C
+
+#######################################################################
+# usage
+#	Print the usage message.
+# Input: none
+# Returns: none
+#
+#######################################################################
+function usage
+{
+	print -u2 "\nUsage: "
+	print -u2 "${progname} iso_file usb_image tmpdir"
+	print -u2 "iso_file  : The path to an existing iso file."
+	print -u2 "usb_image : The path to usb image to be created."
+	print -u2 "tmpdir    : Temporary directy used during usb image " \
+	    "creation.\n"
+
+	print -u2 "If tmpdir does not exist it will be created. If " \
+	    "it or subdirectories under tmpdir can not be created " \
+	    " an error is generated and this script exits."
+	
+}
+
+#######################################################################
+# get_filesize
+#	Get filesize for the file argv[2] and return it to the
+#	variable defined by argv[1].
+# Input:
+#	$1 - variable to return filesize in
+#	$2 - file to query
+#
+# Returns:
+#	$1 - variable to return filesize in
+#
+#	-1 if file does not exist
+#
+#	A non-zero exit code only for internal errors and success
+#	in all other cases
+#
+#######################################################################
+function get_filesize
+{
+	set -o errexit
+	nameref filesize_ret="$1"	# return filesize into this varable
+	typeset filename="$2"		# file to query
+	integer filesize=-1		# temporary integer for "read" below
+	typeset dummy # dummy string
+
+	if [[ -f "${filename}" ]] ; then
+		ls -lb "${filename}" | \
+		    grep "${filename}" | \
+		    read dummy dummy dummy dummy filesize dummy 
+	fi
+
+	(( filesize_ret=filesize ))
+	return 0
+}
+
+#
+#
+#######################################################################
+# cleanup
+#	This function attempst to clean up any resources this script
+#	could generate. Depending on where in the script this function
+#	is involked some resouces may not be there to cleanup, but
+#	that will not adversely effect anything.
+#
+#	This function is not defined using the function keyword
+#	to avoid an exit loop.
+#
+# Input: none
+# Returns: none
+#
+#######################################################################
+cleanup ()
+{
+
+	{
+		trap "" ERR INT
+		set +o errexit
+
+		# unmounting, and uninstalling the lofi'ed devices and
+		# cleanup temporary files.
+		IFS=''
+
+		typeset mount_output="$(mount)"
+
+		[[ "${mount_output}" == ~(E).*"${usb_path}".* ]] && \
+		    umount "${usb_path}"
+
+		[[ "${mount_output}" == ~(E).*"${iso_path}".* ]] && \
+		    umount "${iso_path}"
+
+		lofiadm "${usb_file}" && \
+		    lofiadm -d "${usb_file}"
+
+		lofiadm "${iso_file}"  && \
+		    lofiadm -d "${iso_file}"
+
+		if [[ -d "${iso_path}" ]] ; then
+			rm -rf "${iso_path}"
+		fi
+
+		if [[ -d "${usb_path}" ]] ; then
+			rm -rf "${usb_path}"
+		fi
+
+		#
+		# If the tmpdir did not exist this script could
+		# have created it, so remove it here.
+		#
+		if ! ${tmpdir_existed} ; then
+			rm -rf "${tmpdir}"
+		fi
+	 } > /dev/null 2>&1
+
+}
+
+#######################################################################
+# error_handler
+#	The error_handler for this script. Will cleanup the usb image
+#	that could have been partially created. Then invoke cleanup
+#	to clean up any temporary resouces.
+#
+#	This function is not defined using the function keyword
+#	to avoid an exit loop.
+#
+# Input: none
+# Returns: none
+#
+#######################################################################
+error_handler ()
+{
+	trap "" ERR INT
+	set +o errexit
+
+	print -u2 "\nError:\n"
+	print -u2 -r -- "${progname}: $*"
+	cleanup
+
+	#
+	# If an error was encountered while attempting to create
+	# the new usb image file don't leave a possibley partially
+	# constructed one around.
+	#
+	if [[ -f "${usb_file}" ]] ; then
+		rm -rf "${usb_file}" > /dev/null 2>&1
+	fi
+
+	exit 1
+}
+
+# main
+#######################################################################
+# main
+#
+# Input:
+#	iso_file  : The path to an existing iso file.
+#	usb_image : The path to usb image to be created.
+#	tmpdir    : Temporary directroy used during usb image creation.
+#
+#	If tmpdir does not exist it will be created. If it can not be
+#	created an error is generated and this script exits.
+#
+#	This script must be run as root"
+#
+# Logic Flow:
+#	Set up error handling.
+#	Confirm input arguments.
+#	Create temporary directories.
+#	Mount up the existing ISO image file.
+#	Compute the size for the new USB image.
+#	Create and mount an empty new USB image.
+#	Copy the contents of the ISO file to the new USB image.
+#	Remove GRUB entries from the USB image which apply only to ISO.
+#	Set the file protections for the new USB image.
+#
+# Returns:
+#	1 on failure
+#	0 on success
+#
+#######################################################################
+builtin chmod
+builtin cp
+builtin mkdir
+builtin mv
+builtin rm
+
+typeset -r progname="$0"
+typeset -r iso_file="$1"
+typeset -r tmpdir="$3"
+typeset    tmpdir_existed=true
+typeset -r iso_path="${tmpdir}/iso"
+
+typeset -r usb_file="$2"
+typeset -r usb_path="${tmpdir}/usb"
+float      usb_size # need floating-point for the calculations below
+
+typeset isodev
+typeset devs
+typeset rdevs
+typeset s0devs
+typeset rs0devs
+typeset rs2devs
+
+#
+# Confirm input arguments.
+#
+if [[ $(id) != ~(E).*uid=0\(root\).* ]]; then
+	print -u2 "Error:\nYou must run this script as root"
+	usage
+	exit 1
+fi
+
+if (( $# != 3 )) ; then
+	print -u2 "Error:\nImproper arguments"
+	usage
+	exit 1
+fi
+
+#
+# Set up error handling.
+# Use set -o errexit to trap errors. However, where possible,
+# explicitly check command return status for errors.
+#
+trap "error_handler Error or interrupt encountered. Exiting" ERR INT
+set -o errexit
+
+#
+# Create temporary directories.
+#
+[[ ! -d $tmpdir ]] && tmpdir_existed=false
+mkdir -p "${iso_path}"
+if [[ ! -d "${iso_path}" ]] ; then
+	error_handler "Unable to create or access tmpdir ${iso_path}"
+fi
+
+mkdir -p "${usb_path}"
+if [[ ! -d "${usb_path}" ]] ; then
+	error_handler "Unable to create or access tmpdir ${usb_path}"
+fi
+
+#
+# Mount up the existing ISO image file.
+#
+isodev="$(lofiadm -a "${iso_file}")" || \
+    error_handler "Failed to lofiadm ${iso_file}"
+
+mount -F hsfs "${isodev}" "${iso_path}" || \
+    error_handler "Failed to mount ${isodev} on ${iso_path}"
+
+
+#
+# Compute the size for the new USB image.
+# Use ISO file size + 20% to account for smaller block size on UFS
+# and the log. Round to nearest kbyte plus 512
+# plus 4MB for MBR+SMI label
+#
+get_filesize "usb_size" "${iso_file}"
+if (( usb_size == -1 )) ; then
+	error_handler "Failed to get size of file ${iso_file}"
+fi
+(( usb_size=((int( (usb_size * 1.2) / 1024.) * 1024.) + 512) + 4194304 ))
+
+#
+# Create and mount an empty new USB image.
+#
+mkfile -n ${usb_size} "${usb_file}" || \
+    error_handler "Failed to create file ${usb_file}"
+
+devs="$(lofiadm -la "${usb_file}")" || \
+	error_handler "Failed to lofiadm file ${usb_file}"
+
+#
+# Set rdevs by replacing dsk with rdsk in devs
+#
+rdevs="${devs/dsk/rdsk}"
+# for mount
+s0devs="${devs/p0/s0}"
+# for newfs and installboot
+rs0devs="${rdevs/p0/s0}"
+# for prtvtoc | fmthard
+rs2devs="${rdevs/p0/s2}"
+
+#
+# create Solaris2 partition
+#
+fdisk -B "${rdevs}"
+prtvtoc "${rs2devs}" | nawk '
+/^[^\*]/ { r = $1; for(n = 1; n <= NF; n++) vtoc[r,n] = $n }
+END {
+vtoc[0,1] = 0;
+vtoc[0,2] = 2;
+vtoc[0,3] = 00;
+vtoc[0,4] = vtoc[8,6] + 1;
+vtoc[0,5] = vtoc[2,6] - vtoc[8,6];
+vtoc[0,6] = vtoc[2,6];
+printf("\t%d\t%d\t%02d\t%d\t%d\t%d\n",
+	vtoc[0,1], vtoc[0,2], vtoc[0,3], vtoc[0,4], vtoc[0,5], vtoc[0,6]);
+printf("\t%d\t%d\t%02d\t%d\t%d\t%d\n",
+	vtoc[2,1], vtoc[2,2], vtoc[2,3], vtoc[2,4], vtoc[2,5], vtoc[2,6]);
+printf("\t%d\t%d\t%02d\t%d\t%d\t%d\n",
+	vtoc[8,1], vtoc[8,2], vtoc[8,3], vtoc[8,4], vtoc[8,5], vtoc[8,6]);
+}' | fmthard -s- "${rs2devs}"
+
+# newfs doesn't ask questions if stdin isn't a tty.
+newfs "${rs0devs}" </dev/null || \
+	error_handler "Failed to construct the UFS file system ${rs0devs}"
+
+mount -o nologging "${s0devs}" "${usb_path}" || \
+	error_handler "Failed to mount construct the UFS file system ${rs0devs}"
+
+#
+# Copy the contents of the ISO file to the new USB image.
+#
+print "Copying ISO contents to USB image..."
+(cd "${iso_path}"; find . -print | cpio -pmudV "${usb_path}")
+
+#
+# install bootblocks
+#
+installboot -mf "${usb_path}/boot/pmbr" "${usb_path}/boot/gptzfsboot" \
+	"${rs0devs}"
+
+# If we get an error hereforth in menu.lst modifications, proceed with a warning
+trap "" ERR INT
+set +o errexit
+
+#
+# Remove "Hard Disk" GRUB entries from the USB image as they apply only to ISO.
+#
+nawk '
+	BEGIN { inhard=0 }
+	/^title.*Hard Disk$/ { inhard=1 }
+	/^title/ { if (index($0,"Hard Disk") == 0) inhard=0 }
+	inhard == 0 {print}
+' ${usb_path}/boot/grub/menu.lst > ${usb_path}/boot/grub/menu2.lst
+if [[ $? == 0 ]] ; then
+	mv ${usb_path}/boot/grub/menu2.lst ${usb_path}/boot/grub/menu.lst
+else
+	print -u2 "Warning: Could not remove \"Hard Disk\" entry from boot menu"
+fi
+
+#
+# Set the file protections for the new USB image.
+#
+chmod 444 "${usb_file}"
+
+#
+# unmounting, and uninstalling the lofi'ed devices
+#
+cleanup
+
+printf "=== %s completed at %s\n\n" "$0" "$(date)"
+
+exit 0
+
