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
11231123SnyanMACHINE=`uname -m`
12231123Snyan
13272309Semaste# resolv.conf from DHCP ends up in here, so make sure the directory exists
14272309Semastemkdir /tmp/bsdinstall_etc
15272309Semaste
16225637Snwhitehornkbdcontrol -d >/dev/null 2>&1
17225637Snwhitehornif [ $? -eq 0 ]; then
18230482Snwhitehorn	# Syscons: use xterm, start interesting things on other VTYs
19231123Snyan	if [ ${MACHINE} = "pc98" ]; then
20231123Snyan		TERM=cons25w
21231123Snyan	else
22231123Snyan		TERM=xterm
23231123Snyan	fi
24230482Snwhitehorn
25260680Sdteske	# Don't send ESC on function-key 62/63 (left/right command key)
26260680Sdteske	kbdcontrol -f 62 '' > /dev/null 2>&1
27260680Sdteske	kbdcontrol -f 63 '' > /dev/null 2>&1
28260680Sdteske
29230483Snwhitehorn	if [ -z "$EXTERNAL_VTY_STARTED" ]; then
30230482Snwhitehorn		# Init will clean these processes up if/when the system
31230482Snwhitehorn		# goes multiuser
32230482Snwhitehorn		touch /tmp/bsdinstall_log
33230482Snwhitehorn		tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
34230997Snwhitehorn		/usr/libexec/getty autologin ttyv3 &
35230482Snwhitehorn		EXTERNAL_VTY_STARTED=1
36230482Snwhitehorn	fi
37225637Snwhitehornelse
38225637Snwhitehorn	# Serial or other console
39225637Snwhitehorn	echo
40225637Snwhitehorn	echo "Welcome to FreeBSD!"
41225637Snwhitehorn	echo
42225637Snwhitehorn	echo "Please choose the appropriate terminal type for your system."
43225637Snwhitehorn	echo "Common console types are:"
44225637Snwhitehorn	echo "   ansi     Standard ANSI terminal"
45225637Snwhitehorn	echo "   vt100    VT100 or compatible terminal"
46225637Snwhitehorn	echo "   xterm    xterm terminal emulator (or compatible)"
47231123Snyan	echo "   cons25w  cons25w terminal"
48225637Snwhitehorn	echo
49225637Snwhitehorn	echo -n "Console type [vt100]: "
50225637Snwhitehorn	read TERM
51225637Snwhitehorn	TERM=${TERM:-vt100}
52225637Snwhitehornfi
53225637Snwhitehornexport TERM
54219181Snwhitehorn
55245706Snwhitehornif [ -f /etc/installerconfig ]; then
56245742Snwhitehorn	if bsdinstall script /etc/installerconfig; then
57245706Snwhitehorn		dialog --backtitle "FreeBSD Installer" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of FreeBSD complete! Rebooting in 10 seconds" 10 30 10
58245706Snwhitehorn		reboot
59245706Snwhitehorn	else
60245706Snwhitehorn		dialog --backtitle "FreeBSD Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0
61245706Snwhitehorn	fi
62245706Snwhitehorn	exit 
63245706Snwhitehornfi
64245706Snwhitehorn
65219181Snwhitehorndialog --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
66219181Snwhitehorn
67219181Snwhitehorncase $? in
68219181Snwhitehorn$DIALOG_OK)	# Install
69225637Snwhitehorn	# If not netbooting, have the installer configure the network
70225637Snwhitehorn	dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
71225637Snwhitehorn	if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
72225637Snwhitehorn		BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
73225637Snwhitehorn	fi
74225637Snwhitehorn
75219181Snwhitehorn	trap true SIGINT	# Ignore cntrl-C here
76219181Snwhitehorn	bsdinstall
77220500Snwhitehorn	if [ $? -eq 0 ]; then
78220500Snwhitehorn		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
79220500Snwhitehorn	else
80220500Snwhitehorn		. /etc/rc.local
81220500Snwhitehorn	fi
82219181Snwhitehorn	;;
83219181Snwhitehorn$DIALOG_CANCEL)	# Live CD
84219181Snwhitehorn	exit 0
85219181Snwhitehorn	;;
86219181Snwhitehorn$DIALOG_EXTRA)	# Shell
87219181Snwhitehorn	clear
88219181Snwhitehorn	echo "When finished, type 'exit' to return to the installer."
89219181Snwhitehorn	/bin/sh
90219181Snwhitehorn	. /etc/rc.local
91219181Snwhitehorn	;;
92219181Snwhitehornesac
93219181Snwhitehorn
94