Deleted Added
full compact
jail (256340) jail (258421)
1#!/bin/sh
2#-
3# Copyright (c) 2011 Nathan Whitehorn
1#!/bin/sh
2#-
3# Copyright (c) 2011 Nathan Whitehorn
4# Copyright (c) 2013 Devin Teske
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
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.
15#
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
26# SUCH DAMAGE.
27#
27# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/jail 256340 2013-10-11 20:28:30Z des $
28# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/jail 258421 2013-11-21 03:40:52Z dteske $
29#
30############################################################ INCLUDES
28
31
29echo "Begun Installation at $(date)" > $BSDINSTALL_LOG
32BSDCFG_SHARE="/usr/share/bsdconfig"
33. $BSDCFG_SHARE/common.subr || exit 1
34
35############################################################ MAIN
36
37f_dprintf "Began Installation at %s" "$( date )"
30export BSDINSTALL_CHROOT=$1
31
32error() {
33 dialog --backtitle "FreeBSD Installer" --title "Abort" \
34 --no-label "Exit" --yes-label "Restart" --yesno \
35 "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
36 if [ $? -ne 0 ]; then
37 exit
38 else
39 exec $0 $BSDINSTALL_CHROOT
40 fi
41}
42
43
44rm -rf $BSDINSTALL_TMPETC
45mkdir $BSDINSTALL_TMPETC
46mkdir -p $1 || error
47
48test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
49
50if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
51 exec 3>&1
52 BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
53 MIRROR_BUTTON=$?
54 exec 3>&-
55 test $MIRROR_BUTTON -eq 0 || error
56 export BSDINSTALL_DISTSITE
57 fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error
58fi
59
60export DISTRIBUTIONS="base.txz"
61if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
62 DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base`
63
64 exec 3>&1
65 EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \
66 --backtitle "FreeBSD Installer" \
67 --title "Distribution Select" --nocancel --separate-output \
68 --checklist "Choose optional system components to install:" \
69 0 0 0 \
70 2>&1 1>&3)
71 for dist in $EXTRA_DISTS; do
72 export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
73 done
74fi
75
76FETCH_DISTRIBUTIONS=""
77for dist in $DISTRIBUTIONS; do
78 if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
79 FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
80 fi
81done
82FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
83
84if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
85 exec 3>&1
86 BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3`
87 MIRROR_BUTTON=$?
88 exec 3>&-
89 test $MIRROR_BUTTON -eq 0 || error
90 export BSDINSTALL_DISTSITE
91fi
92
93if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
94 bsdinstall distfetch || error
95fi
96
97bsdinstall checksum || error
98bsdinstall distextract || error
99bsdinstall rootpass || error
100
101trap true SIGINT # This section is optional
102bsdinstall services
103
104dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
105 "Would you like to add users to the installed system now?" 0 0 && \
106 bsdinstall adduser
107
108trap error SIGINT # SIGINT is bad again
109bsdinstall config || error
110cp /etc/resolv.conf $1/etc
111cp /etc/localtime $1/etc
112
113bsdinstall entropy
114
38export BSDINSTALL_CHROOT=$1
39
40error() {
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
44 if [ $? -ne 0 ]; then
45 exit
46 else
47 exec $0 $BSDINSTALL_CHROOT
48 fi
49}
50
51
52rm -rf $BSDINSTALL_TMPETC
53mkdir $BSDINSTALL_TMPETC
54mkdir -p $1 || error
55
56test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
57
58if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
59 exec 3>&1
60 BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
61 MIRROR_BUTTON=$?
62 exec 3>&-
63 test $MIRROR_BUTTON -eq 0 || error
64 export BSDINSTALL_DISTSITE
65 fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error
66fi
67
68export DISTRIBUTIONS="base.txz"
69if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
70 DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base`
71
72 exec 3>&1
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:" \
77 0 0 0 \
78 2>&1 1>&3)
79 for dist in $EXTRA_DISTS; do
80 export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz"
81 done
82fi
83
84FETCH_DISTRIBUTIONS=""
85for dist in $DISTRIBUTIONS; do
86 if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
87 FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
88 fi
89done
90FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space
91
92if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
93 exec 3>&1
94 BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3`
95 MIRROR_BUTTON=$?
96 exec 3>&-
97 test $MIRROR_BUTTON -eq 0 || error
98 export BSDINSTALL_DISTSITE
99fi
100
101if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
102 bsdinstall distfetch || error
103fi
104
105bsdinstall checksum || error
106bsdinstall distextract || error
107bsdinstall rootpass || error
108
109trap true SIGINT # This section is optional
110bsdinstall services
111
112dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
113 "Would you like to add users to the installed system now?" 0 0 && \
114 bsdinstall adduser
115
116trap error SIGINT # SIGINT is bad again
117bsdinstall config || error
118cp /etc/resolv.conf $1/etc
119cp /etc/localtime $1/etc
120
121bsdinstall entropy
122
115echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
123f_dprintf "Installation Completed at %s" "$(date)"
116
124
125################################################################################
126# END
127################################################################################