jail revision 220834
1218799Snwhitehorn#!/bin/sh 2218799Snwhitehorn#- 3218799Snwhitehorn# Copyright (c) 2011 Nathan Whitehorn 4218799Snwhitehorn# All rights reserved. 5218799Snwhitehorn# 6218799Snwhitehorn# Redistribution and use in source and binary forms, with or without 7218799Snwhitehorn# modification, are permitted provided that the following conditions 8218799Snwhitehorn# are met: 9218799Snwhitehorn# 1. Redistributions of source code must retain the above copyright 10218799Snwhitehorn# notice, this list of conditions and the following disclaimer. 11218799Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright 12218799Snwhitehorn# notice, this list of conditions and the following disclaimer in the 13218799Snwhitehorn# documentation and/or other materials provided with the distribution. 14218799Snwhitehorn# 15218799Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16218799Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17218799Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18218799Snwhitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19218799Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20218799Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21218799Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22218799Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23218799Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24218799Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25218799Snwhitehorn# SUCH DAMAGE. 26218799Snwhitehorn# 27218799Snwhitehorn# $FreeBSD: head/usr.sbin/bsdinstall/scripts/jail 220834 2011-04-19 13:54:51Z nwhitehorn $ 28218799Snwhitehorn 29218799Snwhitehornecho "Begun Installation at $(date)" > $BSDINSTALL_LOG 30218799Snwhitehornexport BSDINSTALL_CHROOT=$1 31218799Snwhitehorn 32218799Snwhitehornerror() { 33218799Snwhitehorn dialog --backtitle "FreeBSD Installer" --title "Abort" \ 34218799Snwhitehorn --no-label "Exit" --yes-label "Restart" --yesno \ 35220753Snwhitehorn "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 36218799Snwhitehorn if [ $? -ne 0 ]; then 37218799Snwhitehorn exit 38218799Snwhitehorn else 39220753Snwhitehorn exec $0 $BSDINSTALL_CHROOT 40218799Snwhitehorn fi 41218799Snwhitehorn} 42218799Snwhitehorn 43218799Snwhitehorn 44218799Snwhitehornrm -rf $BSDINSTALL_TMPETC 45218799Snwhitehornmkdir $BSDINSTALL_TMPETC 46220753Snwhitehornmkdir -p $1 || error 47218799Snwhitehorn 48220753Snwhitehorntest ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR 49218799Snwhitehorn 50220753Snwhitehornif [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then 51220753Snwhitehorn exec 3>&1 52220834Snwhitehorn BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) 53220753Snwhitehorn MIRROR_BUTTON=$? 54220753Snwhitehorn exec 3>&- 55220753Snwhitehorn test $MIRROR_BUTTON -eq 0 || error 56220753Snwhitehorn export BSDINSTALL_DISTSITE 57220753Snwhitehorn fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error 58220753Snwhitehornfi 59220753Snwhitehorn 60220753Snwhitehornexport DISTRIBUTIONS="base.txz" 61220753Snwhitehornif [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 62220753Snwhitehorn DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base` 63220753Snwhitehorn 64220753Snwhitehorn exec 3>&1 65220753Snwhitehorn EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \ 66220753Snwhitehorn --backtitle "FreeBSD Installer" \ 67220753Snwhitehorn --title "Distribution Select" --nocancel --separate-output \ 68220753Snwhitehorn --checklist "Choose optional system components to install:" \ 69220753Snwhitehorn 0 0 0 \ 70220753Snwhitehorn 2>&1 1>&3) 71220753Snwhitehorn for dist in $EXTRA_DISTS; do 72220753Snwhitehorn export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 73220753Snwhitehorn done 74220753Snwhitehornfi 75220753Snwhitehorn 76218799SnwhitehornFETCH_DISTRIBUTIONS="" 77218799Snwhitehornfor dist in $DISTRIBUTIONS; do 78218799Snwhitehorn if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 79218799Snwhitehorn FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 80218799Snwhitehorn fi 81218799Snwhitehorndone 82220753SnwhitehornFETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space 83218799Snwhitehorn 84220753Snwhitehornif [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then 85220753Snwhitehorn exec 3>&1 86220753Snwhitehorn BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` 87220753Snwhitehorn MIRROR_BUTTON=$? 88220753Snwhitehorn exec 3>&- 89220753Snwhitehorn test $MIRROR_BUTTON -eq 0 || error 90220753Snwhitehorn export BSDINSTALL_DISTSITE 91220753Snwhitehornfi 92220753Snwhitehorn 93220753Snwhitehornif [ ! -z "$FETCH_DISTRIBUTIONS" ]; then 94218799Snwhitehorn bsdinstall distfetch || error 95218799Snwhitehornfi 96218799Snwhitehorn 97220753Snwhitehornbsdinstall checksum || error 98218799Snwhitehornbsdinstall distextract || error 99218799Snwhitehornbsdinstall rootpass || error 100218799Snwhitehorn 101218799Snwhitehorntrap true SIGINT # This section is optional 102218799Snwhitehornbsdinstall services 103218799Snwhitehorn 104218799Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \ 105218799Snwhitehorn "Would you like to add users to the installed system now?" 0 0 && \ 106218799Snwhitehorn bsdinstall adduser 107218799Snwhitehorn 108218799Snwhitehorntrap error SIGINT # SIGINT is bad again 109218799Snwhitehornbsdinstall config || error 110220753Snwhitehorncp /etc/resolv.conf $1/etc 111220753Snwhitehorncp /etc/localtime $1/etc 112218799Snwhitehorn 113218799Snwhitehornecho "Installation Completed at $(date)" >> $BSDINSTALL_LOG 114218799Snwhitehorn 115