xref: /freebsd/usr.sbin/bsdinstall/scripts/jail (revision aa0a1e58)
1#!/bin/sh
2#-
3# Copyright (c) 2011 Nathan Whitehorn
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#
27# $FreeBSD$
28
29echo "Begun Installation at $(date)" > $BSDINSTALL_LOG
30
31export BSDINSTALL_CHROOT=$1
32export DISTRIBUTIONS="kernel.txz base.txz doc.txz games.txz"
33[ `uname -p` = amd64 -o `uname -p` = powerpc64 ] && export DISTRIBUTIONS="$DISTRIBUTIONS lib32.txz"
34
35error() {
36	dialog --backtitle "FreeBSD Installer" --title "Abort" \
37	    --no-label "Exit" --yes-label "Restart" --yesno \
38	    "You have canceled an installation step. Would you like to restart the installation or exit the installer?" 0 0
39	if [ $? -ne 0 ]; then
40		exit
41	else
42		test -f $PATH_FSTAB && bsdinstall umount
43		exec $0
44	fi
45}
46
47
48rm -rf $BSDINSTALL_TMPETC
49mkdir $BSDINSTALL_TMPETC
50
51trap error SIGINT	# SIGINT is bad
52
53FETCH_DISTRIBUTIONS=""
54for dist in $DISTRIBUTIONS; do
55	if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
56		FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
57	fi
58done
59
60if [ ! -z $FETCH_DISTRIBUTIONS ]; then
61	ALL_DISTRIBUTIONS=$DISTRIBUTIONS
62	DISTRIBUTIONS=$FETCH_DISTRIBUTIONS
63	bsdinstall distfetch || error
64	DISTRIBUTIONS=$ALL_DISTRIBUTIONS
65fi
66
67bsdinstall distextract || error
68bsdinstall rootpass || error
69
70trap true SIGINT	# This section is optional
71bsdinstall time
72bsdinstall services
73
74dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
75    "Would you like to add users to the installed system now?" 0 0 && \
76    bsdinstall adduser
77
78trap error SIGINT	# SIGINT is bad again
79bsdinstall config  || error
80
81echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
82
83