]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/rc.local
Remove $FreeBSD$: one-line sh pattern
[FreeBSD/FreeBSD.git] / release / rc.local
1 #!/bin/sh
2
3 : ${DIALOG_OK=0}
4 : ${DIALOG_CANCEL=1}
5 : ${DIALOG_HELP=2}
6 : ${DIALOG_EXTRA=3}
7 : ${DIALOG_ITEM_HELP=4}
8 : ${DIALOG_ESC=255}
9
10 MACHINE=`uname -m`
11
12 # resolv.conf from DHCP ends up in here, so make sure the directory exists
13 mkdir /tmp/bsdinstall_etc
14
15 kbdcontrol -d >/dev/null 2>&1
16 if [ $? -eq 0 ]; then
17         # Syscons: use xterm, start interesting things on other VTYs
18         TERM=xterm
19
20         # Don't send ESC on function-key 62/63 (left/right command key)
21         kbdcontrol -f 62 '' > /dev/null 2>&1
22         kbdcontrol -f 63 '' > /dev/null 2>&1
23
24         if [ -z "$EXTERNAL_VTY_STARTED" ]; then
25                 # Init will clean these processes up if/when the system
26                 # goes multiuser
27                 touch /tmp/bsdinstall_log
28                 tail -f /tmp/bsdinstall_log > /dev/ttyv2 &
29                 /usr/libexec/getty autologin ttyv3 &
30                 EXTERNAL_VTY_STARTED=1
31         fi
32 else
33         # Serial or other console
34         echo
35         echo "Welcome to FreeBSD!"
36         echo
37         echo "Please choose the appropriate terminal type for your system."
38         echo "Common console types are:"
39         echo "   ansi     Standard ANSI terminal"
40         echo "   vt100    VT100 or compatible terminal"
41         echo "   xterm    xterm terminal emulator (or compatible)"
42         echo "   cons25w  cons25w terminal"
43         echo
44         echo -n "Console type [vt100]: "
45         read TERM
46         TERM=${TERM:-vt100}
47 fi
48 export TERM
49
50 if [ -f /etc/installerconfig ]; then
51         if bsdinstall script /etc/installerconfig; then
52                 dialog --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                 dialog --backtitle "FreeBSD Installer" --title "Error" --textbox /tmp/bsdinstall_log 0 0
56         fi
57         exit 
58 fi
59
60 dialog --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
62 case $? in
63 $DIALOG_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                 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
74         else
75                 . /etc/rc.local
76         fi
77         ;;
78 $DIALOG_CANCEL) # Live CD
79         exit 0
80         ;;
81 $DIALOG_EXTRA)  # Shell
82         clear
83         echo "When finished, type 'exit' to return to the installer."
84         /bin/sh
85         . /etc/rc.local
86         ;;
87 esac
88