xref: /freebsd/usr.sbin/bsdinstall/startbsdinstall (revision a09af1b7fd95d9479954c5b8e96a126cad468424)
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 [ "$1" != "primary" ]; then
49		bsddialog --backtitle "FreeBSD Installer" --title "Installing" --msgbox "FreeBSD is being installed from a script; please use the primary console." 0 0
50		. "$0"
51	elif bsdinstall script /etc/installerconfig; then
52		bsddialog --backtitle "FreeBSD Installer" --title "Complete" --no-cancel --ok-label "Reboot" --pause "Installation of FreeBSD complete! Rebooting in 10 seconds" 10 30 10
53		reboot
54	else
55		bsddialog --backtitle "FreeBSD Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0
56	fi
57	exit
58fi
59
60bsddialog --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
61
62case $? in
63$BSDDIALOG_OK)	# Install
64	# If not netbooting, have the installer configure the network
65	dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
66	if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
67		BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
68	fi
69
70	trap true SIGINT	# Ignore cntrl-C here
71	bsdinstall
72	if [ $? -eq 0 ]; then
73		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
74
75		case $? in
76		$BSDDIALOG_OK)		# Reboot
77			reboot
78			;;
79		$BSDDIALOG_EXTRA)	# Shutdown
80			shutdown -p now
81			;;
82		$BSDDIALOG_CANCEL)	# Live CD
83			exit 0
84			;;
85		esac
86	else
87		. "$0"
88	fi
89	;;
90$BSDDIALOG_CANCEL)	# Live CD
91	exit 0
92	;;
93$BSDDIALOG_EXTRA)	# Shell
94	clear
95	echo "When finished, type 'exit' to return to the installer."
96	/bin/sh
97	. "$0"
98	;;
99esac
100
101