rc.local revision 230483
118099Spst#!/bin/sh
218099Spst# $FreeBSD: head/release/rc.local 230483 2012-01-23 15:50:16Z nwhitehorn $
318099Spst
418099Spst: ${DIALOG_OK=0}
569626Sru: ${DIALOG_CANCEL=1}
669626Sru: ${DIALOG_HELP=2}
7104862Sru: ${DIALOG_EXTRA=3}
8104862Sru: ${DIALOG_ITEM_HELP=4}
9104862Sru: ${DIALOG_ESC=255}
10104862Sru
11104862Srukbdcontrol -d >/dev/null 2>&1
12104862Sruif [ $? -eq 0 ]; then
13104862Sru	# Syscons: use xterm, start interesting things on other VTYs
14151497Sru	TERM=xterm
15151497Sru
16151497Sru	if [ -z "$EXTERNAL_VTY_STARTED" ]; then
17151497Sru		vidcontrol -s 2 # Switch to a VTY with no kernel messages
18151497Sru		# Init will clean these processes up if/when the system
19151497Sru		# goes multiuser
20151497Sru		touch /tmp/bsdinstall_log
21151497Sru		tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
22151497Sru		/usr/libexec/getty autologin ttyv3
23151497Sru		EXTERNAL_VTY_STARTED=1
24151497Sru		trap "vidcontrol -s 1" EXIT
25151497Sru	fi
26151497Sruelse
27151497Sru	# Serial or other console
28151497Sru	echo
29151497Sru	echo "Welcome to FreeBSD!"
30151497Sru	echo
31151497Sru	echo "Please choose the appropriate terminal type for your system."
32151497Sru	echo "Common console types are:"
33151497Sru	echo "   ansi     Standard ANSI terminal"
34151497Sru	echo "   vt100    VT100 or compatible terminal"
35151497Sru	echo "   xterm    xterm terminal emulator (or compatible)"
36151497Sru	echo
37151497Sru	echo -n "Console type [vt100]: "
38151497Sru	read TERM
39151497Sru	TERM=${TERM:-vt100}
40151497Srufi
41151497Sruexport TERM
42151497Sru
43151497Srudialog --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
44151497Sru
45151497Srucase $? in
46151497Sru$DIALOG_OK)	# Install
47151497Sru	# If not netbooting, have the installer configure the network
48151497Sru	dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
49151497Sru	if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
50151497Sru		BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
51151497Sru	fi
52151497Sru
53151497Sru	trap true SIGINT	# Ignore cntrl-C here
54151497Sru	bsdinstall
55151497Sru	if [ $? -eq 0 ]; then
56151497Sru		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
57151497Sru	else
58151497Sru		. /etc/rc.local
59151497Sru	fi
60151497Sru	;;
61151497Sru$DIALOG_CANCEL)	# Live CD
62151497Sru	exit 0
63151497Sru	;;
64151497Sru$DIALOG_EXTRA)	# Shell
65151497Sru	clear
66151497Sru	echo "When finished, type 'exit' to return to the installer."
67151497Sru	/bin/sh
68151497Sru	. /etc/rc.local
69151497Sru	;;
70151497Sruesac
71151497Sru
72151497Sru