1#!/bin/sh
2# $FreeBSD$
3
4: ${DIALOG_OK=0}
5: ${DIALOG_CANCEL=1}
6: ${DIALOG_HELP=2}
7: ${DIALOG_EXTRA=3}
8: ${DIALOG_ITEM_HELP=4}
9: ${DIALOG_ESC=255}
10
11MACHINE=`uname -m`
12
13# resolv.conf from DHCP ends up in here, so make sure the directory exists
14mkdir /tmp/bsdinstall_etc
15
16kbdcontrol -d >/dev/null 2>&1
17if [ $? -eq 0 ]; then
18	# Syscons: use xterm, start interesting things on other VTYs
19	if [ ${MACHINE} = "pc98" ]; then
20		TERM=cons25w
21	else
22		TERM=xterm
23	fi
24
25	# Don't send ESC on function-key 62/63 (left/right command key)
26	kbdcontrol -f 62 '' > /dev/null 2>&1
27	kbdcontrol -f 63 '' > /dev/null 2>&1
28
29	if [ -z "$EXTERNAL_VTY_STARTED" ]; then
30		# Init will clean these processes up if/when the system
31		# goes multiuser
32		touch /tmp/bsdinstall_log
33		tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
34		/usr/libexec/getty autologin ttyv3 &
35		EXTERNAL_VTY_STARTED=1
36	fi
37else
38	# Serial or other console
39	echo
40	echo "Welcome to FreeBSD!"
41	echo
42	echo "Please choose the appropriate terminal type for your system."
43	echo "Common console types are:"
44	echo "   ansi     Standard ANSI terminal"
45	echo "   vt100    VT100 or compatible terminal"
46	echo "   xterm    xterm terminal emulator (or compatible)"
47	echo "   cons25w  cons25w terminal"
48	echo
49	echo -n "Console type [vt100]: "
50	read TERM
51	TERM=${TERM:-vt100}
52fi
53export TERM
54
55if [ -f /etc/installerconfig ]; then
56	if bsdinstall script /etc/installerconfig; then
57		dialog --backtitle "FreeBSD Installer" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of FreeBSD complete! Rebooting in 10 seconds" 10 30 10
58		reboot
59	else
60		dialog --backtitle "FreeBSD Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0
61	fi
62	exit 
63fi
64
65dialog --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
66
67case $? in
68$DIALOG_OK)	# Install
69	# If not netbooting, have the installer configure the network
70	dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
71	if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
72		BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
73	fi
74
75	trap true SIGINT	# Ignore cntrl-C here
76	bsdinstall
77	if [ $? -eq 0 ]; then
78		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
79	else
80		. /etc/rc.local
81	fi
82	;;
83$DIALOG_CANCEL)	# Live CD
84	exit 0
85	;;
86$DIALOG_EXTRA)	# Shell
87	clear
88	echo "When finished, type 'exit' to return to the installer."
89	/bin/sh
90	. /etc/rc.local
91	;;
92esac
93
94