rc.local revision 230482
1219181Snwhitehorn#!/bin/sh
2219181Snwhitehorn# $FreeBSD: head/release/rc.local 230482 2012-01-23 15:44:52Z nwhitehorn $
3219181Snwhitehorn
4219181Snwhitehorn: ${DIALOG_OK=0}
5219181Snwhitehorn: ${DIALOG_CANCEL=1}
6219181Snwhitehorn: ${DIALOG_HELP=2}
7219181Snwhitehorn: ${DIALOG_EXTRA=3}
8219181Snwhitehorn: ${DIALOG_ITEM_HELP=4}
9219181Snwhitehorn: ${DIALOG_ESC=255}
10219181Snwhitehorn
11225637Snwhitehornkbdcontrol -d >/dev/null 2>&1
12225637Snwhitehornif [ $? -eq 0 ]; then
13230482Snwhitehorn	# Syscons: use xterm, start interesting things on other VTYs
14225637Snwhitehorn	TERM=xterm
15230482Snwhitehorn
16230482Snwhitehorn	if [ "$EXTERNAL_VTY_STARTED" -ne 1 ]; then
17230482Snwhitehorn		vidcontrol -s 2 # Switch to a VTY with no kernel messages
18230482Snwhitehorn		# Init will clean these processes up if/when the system
19230482Snwhitehorn		# goes multiuser
20230482Snwhitehorn		touch /tmp/bsdinstall_log
21230482Snwhitehorn		tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
22230482Snwhitehorn		/usr/libexec/getty autologin ttyv3
23230482Snwhitehorn		EXTERNAL_VTY_STARTED=1
24230482Snwhitehorn		trap "vidcontrol -s 1" EXIT
25230482Snwhitehorn	fi
26225637Snwhitehornelse
27225637Snwhitehorn	# Serial or other console
28225637Snwhitehorn	echo
29225637Snwhitehorn	echo "Welcome to FreeBSD!"
30225637Snwhitehorn	echo
31225637Snwhitehorn	echo "Please choose the appropriate terminal type for your system."
32225637Snwhitehorn	echo "Common console types are:"
33225637Snwhitehorn	echo "   ansi     Standard ANSI terminal"
34225637Snwhitehorn	echo "   vt100    VT100 or compatible terminal"
35225637Snwhitehorn	echo "   xterm    xterm terminal emulator (or compatible)"
36225637Snwhitehorn	echo
37225637Snwhitehorn	echo -n "Console type [vt100]: "
38225637Snwhitehorn	read TERM
39225637Snwhitehorn	TERM=${TERM:-vt100}
40225637Snwhitehornfi
41225637Snwhitehornexport TERM
42219181Snwhitehorn
43219181Snwhitehorndialog --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
44219181Snwhitehorn
45219181Snwhitehorncase $? in
46219181Snwhitehorn$DIALOG_OK)	# Install
47225637Snwhitehorn	# If not netbooting, have the installer configure the network
48225637Snwhitehorn	dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
49225637Snwhitehorn	if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then
50225637Snwhitehorn		BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT
51225637Snwhitehorn	fi
52225637Snwhitehorn
53219181Snwhitehorn	trap true SIGINT	# Ignore cntrl-C here
54219181Snwhitehorn	bsdinstall
55220500Snwhitehorn	if [ $? -eq 0 ]; then
56220500Snwhitehorn		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
57220500Snwhitehorn	else
58220500Snwhitehorn		. /etc/rc.local
59220500Snwhitehorn	fi
60219181Snwhitehorn	;;
61219181Snwhitehorn$DIALOG_CANCEL)	# Live CD
62219181Snwhitehorn	exit 0
63219181Snwhitehorn	;;
64219181Snwhitehorn$DIALOG_EXTRA)	# Shell
65219181Snwhitehorn	clear
66219181Snwhitehorn	echo "When finished, type 'exit' to return to the installer."
67219181Snwhitehorn	/bin/sh
68219181Snwhitehorn	. /etc/rc.local
69219181Snwhitehorn	;;
70219181Snwhitehornesac
71219181Snwhitehorn
72