3 # Copyright (c) 2011 Nathan Whitehorn
4 # Copyright (c) 2013 Devin Teske
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 ############################################################ INCLUDES
32 BSDCFG_SHARE="/usr/share/bsdconfig"
33 . $BSDCFG_SHARE/common.subr || exit 1
35 ############################################################ MAIN
37 f_dprintf "Began Installation at %s" "$( date )"
38 export BSDINSTALL_CHROOT=$1
41 dialog --backtitle "FreeBSD Installer" --title "Abort" \
42 --no-label "Exit" --yes-label "Restart" --yesno \
43 "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
47 exec $0 $BSDINSTALL_CHROOT
52 rm -rf $BSDINSTALL_TMPETC
53 mkdir $BSDINSTALL_TMPETC
56 test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
58 if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
60 BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
63 test $MIRROR_BUTTON -eq 0 || error
64 export BSDINSTALL_DISTSITE
65 fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error
68 export DISTRIBUTIONS="base.txz"
69 if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
70 DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base`
73 EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \
74 --backtitle "FreeBSD Installer" \
75 --title "Distribution Select" --nocancel --separate-output \
76 --checklist "Choose optional system components to install:" \
79 for dist in $EXTRA_DISTS; do
80 export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
84 FETCH_DISTRIBUTIONS=""
85 for dist in $DISTRIBUTIONS; do
86 if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
87 FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
90 FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
92 if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
94 BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3`
97 test $MIRROR_BUTTON -eq 0 || error
98 export BSDINSTALL_DISTSITE
101 if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
102 bsdinstall distfetch || error
105 bsdinstall checksum || error
106 bsdinstall distextract || error
107 bsdinstall rootpass || error
109 trap true SIGINT # This section is optional
112 dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
113 "Would you like to add users to the installed system now?" 0 0 && \
116 trap error SIGINT # SIGINT is bad again
117 bsdinstall config || error
118 cp /etc/resolv.conf $1/etc
119 cp /etc/localtime $1/etc
123 f_dprintf "Installation Completed at %s" "$(date)"
125 ################################################################################
127 ################################################################################