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