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