1d577d617SJessica Clarke#!/bin/sh 2d577d617SJessica Clarke 3*cd724c25SMariusz ZaborskiBSDCFG_SHARE="/usr/share/bsdconfig" 4*cd724c25SMariusz Zaborski. $BSDCFG_SHARE/common.subr || exit 1 5*cd724c25SMariusz Zaborski 6d577d617SJessica Clarke: ${BSDDIALOG_OK=0} 7d577d617SJessica Clarke: ${BSDDIALOG_CANCEL=1} 8d577d617SJessica Clarke: ${BSDDIALOG_HELP=2} 9d577d617SJessica Clarke: ${BSDDIALOG_EXTRA=3} 10d577d617SJessica Clarke: ${BSDDIALOG_ESC=5} 11d577d617SJessica Clarke: ${BSDDIALOG_ERROR=255} 12d577d617SJessica Clarke 13d577d617SJessica Clarkekbdcontrol -d >/dev/null 2>&1 14d577d617SJessica Clarkeif [ $? -eq 0 ]; then 15d577d617SJessica Clarke # Syscons: use xterm, start interesting things on other VTYs 16d577d617SJessica Clarke TERM=xterm 17d577d617SJessica Clarke 18d577d617SJessica Clarke # Don't send ESC on function-key 62/63 (left/right command key) 19d577d617SJessica Clarke kbdcontrol -f 62 '' > /dev/null 2>&1 20d577d617SJessica Clarke kbdcontrol -f 63 '' > /dev/null 2>&1 21d577d617SJessica Clarke 22d577d617SJessica Clarke if [ -z "$EXTERNAL_VTY_STARTED" ]; then 23d577d617SJessica Clarke # Init will clean these processes up if/when the system 24d577d617SJessica Clarke # goes multiuser 25d577d617SJessica Clarke touch /tmp/bsdinstall_log 26d577d617SJessica Clarke tail -f /tmp/bsdinstall_log > /dev/ttyv2 & 27d577d617SJessica Clarke /usr/libexec/getty autologin ttyv3 & 28d577d617SJessica Clarke EXTERNAL_VTY_STARTED=1 29d577d617SJessica Clarke fi 30d577d617SJessica Clarkeelse 31d577d617SJessica Clarke # Serial or other console 32d577d617SJessica Clarke echo 33*cd724c25SMariusz Zaborski echo "Welcome to ${OSNAME}!" 34d577d617SJessica Clarke echo 35d577d617SJessica Clarke echo "Please choose the appropriate terminal type for your system." 36d577d617SJessica Clarke echo "Common console types are:" 37d577d617SJessica Clarke echo " ansi Standard ANSI terminal" 38d577d617SJessica Clarke echo " vt100 VT100 or compatible terminal" 39d577d617SJessica Clarke echo " xterm xterm terminal emulator (or compatible)" 40d577d617SJessica Clarke echo 41d577d617SJessica Clarke echo -n "Console type [vt100]: " 42d577d617SJessica Clarke read TERM 43d577d617SJessica Clarke TERM=${TERM:-vt100} 44d577d617SJessica Clarkefi 45d577d617SJessica Clarkeexport TERM 46d577d617SJessica Clarke 47d577d617SJessica Clarke# Query terminal size; useful for serial lines. 48d577d617SJessica Clarkeresizewin -z 49d577d617SJessica Clarke 50d577d617SJessica Clarkeif [ -f /etc/installerconfig ]; then 51a09af1b7SJessica Clarke if [ "$1" != "primary" ]; then 52*cd724c25SMariusz Zaborski bsddialog --backtitle "${OSNAME} Installer" --title "Installing" --msgbox "${OSNAME} is being installed from a script; please use the primary console." 0 0 53a09af1b7SJessica Clarke . "$0" 54a09af1b7SJessica Clarke elif bsdinstall script /etc/installerconfig; then 55*cd724c25SMariusz Zaborski bsddialog --backtitle "${OSNAME} Installer" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of ${OSNAME} complete! Rebooting in 10 seconds" 10 30 10 56d577d617SJessica Clarke reboot 57d577d617SJessica Clarke else 58*cd724c25SMariusz Zaborski bsddialog --backtitle "${OSNAME} Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0 59d577d617SJessica Clarke fi 60d577d617SJessica Clarke exit 61d577d617SJessica Clarkefi 62d577d617SJessica Clarke 63*cd724c25SMariusz Zaborskibsddialog --backtitle "${OSNAME} Installer" --title "Welcome" --extra-button --extra-label "Shell" --ok-label "Install" --cancel-label "Live System" --yesno "Welcome to ${OSNAME}! Would you like to begin an installation or use the live system?" 0 0 64d577d617SJessica Clarke 65d577d617SJessica Clarkecase $? in 66d577d617SJessica Clarke$BSDDIALOG_OK) # Install 67d577d617SJessica Clarke # If not netbooting, have the installer configure the network 68d577d617SJessica Clarke dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` 69d577d617SJessica Clarke if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then 70d577d617SJessica Clarke BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT 71d577d617SJessica Clarke fi 72d577d617SJessica Clarke 73d577d617SJessica Clarke trap true SIGINT # Ignore cntrl-C here 74d577d617SJessica Clarke bsdinstall 75d577d617SJessica Clarke if [ $? -eq 0 ]; then 76*cd724c25SMariusz Zaborski bsddialog --backtitle "${OSNAME} Installer" --title "Complete" --ok-label "Reboot" --extra-button --extra-label "Shutdown" --cancel-label "Live System" --yesno "Installation of ${OSNAME} complete! Would you like to reboot into the installed system now?" 0 0 77d577d617SJessica Clarke 78d577d617SJessica Clarke case $? in 79d577d617SJessica Clarke $BSDDIALOG_OK) # Reboot 80d577d617SJessica Clarke reboot 81d577d617SJessica Clarke ;; 82d577d617SJessica Clarke $BSDDIALOG_EXTRA) # Shutdown 83d577d617SJessica Clarke shutdown -p now 84a4504856SJessica Clarke # shutdown(8) daemonizes, with the actual signal to 85a4504856SJessica Clarke # init(8) happening in the child, but if we exit the 86a4504856SJessica Clarke # script then runconsoles will clean up its children 87a4504856SJessica Clarke # thinking we're trying to go multiuser (and if the 88a4504856SJessica Clarke # user has disabled multiple console support we'll 89a4504856SJessica Clarke # still start trying to go multi-user, which gives 90a4504856SJessica Clarke # confusing output on the console if the daemon is slow 91a4504856SJessica Clarke # to run). Thus we spin while the daemon runs. 92a4504856SJessica Clarke while true; do 93a4504856SJessica Clarke sleep 1 94a4504856SJessica Clarke done 95d577d617SJessica Clarke ;; 9619bb1886SPierre Pronchery $BSDDIALOG_CANCEL) # Live System 97d577d617SJessica Clarke exit 0 98d577d617SJessica Clarke ;; 99d577d617SJessica Clarke esac 100d577d617SJessica Clarke else 101d577d617SJessica Clarke . "$0" 102d577d617SJessica Clarke fi 103d577d617SJessica Clarke ;; 10419bb1886SPierre Pronchery$BSDDIALOG_CANCEL) # Live System 105d577d617SJessica Clarke exit 0 106d577d617SJessica Clarke ;; 107d577d617SJessica Clarke$BSDDIALOG_EXTRA) # Shell 108d577d617SJessica Clarke clear 109d577d617SJessica Clarke echo "When finished, type 'exit' to return to the installer." 110d577d617SJessica Clarke /bin/sh 111d577d617SJessica Clarke . "$0" 112d577d617SJessica Clarke ;; 113d577d617SJessica Clarkeesac 114d577d617SJessica Clarke 115