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