1219181Snwhitehorn#!/bin/sh
2219181Snwhitehorn# $FreeBSD$
3219181Snwhitehorn
4219181Snwhitehorn: ${DIALOG_OK=0}
5219181Snwhitehorn: ${DIALOG_CANCEL=1}
6219181Snwhitehorn: ${DIALOG_HELP=2}
7219181Snwhitehorn: ${DIALOG_EXTRA=3}
8219181Snwhitehorn: ${DIALOG_ITEM_HELP=4}
9219181Snwhitehorn: ${DIALOG_ESC=255}
10219181Snwhitehorn
11231758SnyanMACHINE=`uname -m`
12231758Snyan
13225637Snwhitehornkbdcontrol -d >/dev/null 2>&1
14225637Snwhitehornif [ $? -eq 0 ]; then
15232427Snwhitehorn	# Syscons: use xterm, start interesting things on other VTYs
16231758Snyan	if [ ${MACHINE} = "pc98" ]; then
17231758Snyan		TERM=cons25w
18231758Snyan	else
19231758Snyan		TERM=xterm
20231758Snyan	fi
21232427Snwhitehorn
22263956Sdteske	# Don't send ESC on function-key 62/63 (left/right command key)
23263956Sdteske	kbdcontrol -f 62 '' > /dev/null 2>&1
24263956Sdteske	kbdcontrol -f 63 '' > /dev/null 2>&1
25263956Sdteske
26232427Snwhitehorn	if [ -z "$EXTERNAL_VTY_STARTED" ]; then
27232427Snwhitehorn		# Init will clean these processes up if/when the system
28232427Snwhitehorn		# goes multiuser
29232427Snwhitehorn		touch /tmp/bsdinstall_log
30232427Snwhitehorn		tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
31232427Snwhitehorn		/usr/libexec/getty autologin ttyv3 &
32232427Snwhitehorn		EXTERNAL_VTY_STARTED=1
33232427Snwhitehorn	fi
34225637Snwhitehornelse
35225637Snwhitehorn	# Serial or other console
36225637Snwhitehorn	echo
37225637Snwhitehorn	echo "Welcome to FreeBSD!"
38225637Snwhitehorn	echo
39225637Snwhitehorn	echo "Please choose the appropriate terminal type for your system."
40225637Snwhitehorn	echo "Common console types are:"
41225637Snwhitehorn	echo "   ansi     Standard ANSI terminal"
42225637Snwhitehorn	echo "   vt100    VT100 or compatible terminal"
43225637Snwhitehorn	echo "   xterm    xterm terminal emulator (or compatible)"
44231758Snyan	echo "   cons25w  cons25w terminal"
45225637Snwhitehorn	echo
46225637Snwhitehorn	echo -n "Console type [vt100]: "
47225637Snwhitehorn	read TERM
48225637Snwhitehorn	TERM=${TERM:-vt100}
49225637Snwhitehornfi
50225637Snwhitehornexport TERM
51219181Snwhitehorn
52248240Snwhitehornif [ -f /etc/installerconfig ]; then
53248241Snwhitehorn	if bsdinstall script /etc/installerconfig; then
54248240Snwhitehorn		dialog --backtitle "FreeBSD Installer" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of FreeBSD complete! Rebooting in 10 seconds" 10 30 10
55248240Snwhitehorn		reboot
56248240Snwhitehorn	else
57248240Snwhitehorn		dialog --backtitle "FreeBSD Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0
58248240Snwhitehorn	fi
59248240Snwhitehorn	exit 
60248240Snwhitehornfi
61248240Snwhitehorn
62219181Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Welcome" --extra-button --extra-label "Shell" --ok-label "Install" --cancel-label "Live CD" --yesno "Welcome to FreeBSD! Would you like to begin an installation or use the live CD?" 0 0
63219181Snwhitehorn
64219181Snwhitehorncase $? in
65219181Snwhitehorn$DIALOG_OK)	# Install
66225637Snwhitehorn	# If not netbooting, have the installer configure the network
67225637Snwhitehorn	dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
68225637Snwhitehorn	if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
69225637Snwhitehorn		BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
70225637Snwhitehorn	fi
71225637Snwhitehorn
72219181Snwhitehorn	trap true SIGINT	# Ignore cntrl-C here
73219181Snwhitehorn	bsdinstall
74220500Snwhitehorn	if [ $? -eq 0 ]; then
75220500Snwhitehorn		dialog --backtitle "FreeBSD Installer" --title "Complete" --yes-label "Reboot" --no-label "Live CD" --yesno "Installation of FreeBSD complete! Would you like to reboot into the installed system now?" 0 0 && reboot
76220500Snwhitehorn	else
77220500Snwhitehorn		. /etc/rc.local
78220500Snwhitehorn	fi
79219181Snwhitehorn	;;
80219181Snwhitehorn$DIALOG_CANCEL)	# Live CD
81219181Snwhitehorn	exit 0
82219181Snwhitehorn	;;
83219181Snwhitehorn$DIALOG_EXTRA)	# Shell
84219181Snwhitehorn	clear
85219181Snwhitehorn	echo "When finished, type 'exit' to return to the installer."
86219181Snwhitehorn	/bin/sh
87219181Snwhitehorn	. /etc/rc.local
88219181Snwhitehorn	;;
89219181Snwhitehornesac
90219181Snwhitehorn
91