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