1218799Snwhitehorn#!/bin/sh 2218799Snwhitehorn#- 3218799Snwhitehorn# Copyright (c) 2011 Nathan Whitehorn 4287688Sdteske# Copyright (c) 2013-2015 Devin Teske 5218799Snwhitehorn# All rights reserved. 6218799Snwhitehorn# 7218799Snwhitehorn# Redistribution and use in source and binary forms, with or without 8218799Snwhitehorn# modification, are permitted provided that the following conditions 9218799Snwhitehorn# are met: 10218799Snwhitehorn# 1. Redistributions of source code must retain the above copyright 11218799Snwhitehorn# notice, this list of conditions and the following disclaimer. 12218799Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright 13218799Snwhitehorn# notice, this list of conditions and the following disclaimer in the 14218799Snwhitehorn# documentation and/or other materials provided with the distribution. 15218799Snwhitehorn# 16218799Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17218799Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18218799Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19218799Snwhitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20218799Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21218799Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22218799Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23218799Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24218799Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25218799Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26218799Snwhitehorn# SUCH DAMAGE. 27218799Snwhitehorn# 28218799Snwhitehorn# $FreeBSD$ 29257842Sdteske# 30257842Sdteske############################################################ INCLUDES 31218799Snwhitehorn 32257842SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 33257842Sdteske. $BSDCFG_SHARE/common.subr || exit 1 34257842Sdteske 35257842Sdteske############################################################ MAIN 36257842Sdteske 37257842Sdteskef_dprintf "Began Installation at %s" "$( date )" 38218799Snwhitehornexport BSDINSTALL_CHROOT=$1 39218799Snwhitehorn 40218799Snwhitehornerror() { 41269653Sthompsa local msg 42269653Sthompsa if [ -n "$1" ]; then 43269653Sthompsa msg="$1\n\n" 44269653Sthompsa fi 45218799Snwhitehorn dialog --backtitle "FreeBSD Installer" --title "Abort" \ 46218799Snwhitehorn --no-label "Exit" --yes-label "Restart" --yesno \ 47269653Sthompsa "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 48218799Snwhitehorn if [ $? -ne 0 ]; then 49218799Snwhitehorn exit 50218799Snwhitehorn else 51220753Snwhitehorn exec $0 $BSDINSTALL_CHROOT 52218799Snwhitehorn fi 53218799Snwhitehorn} 54218799Snwhitehorn 55218799Snwhitehorn 56218799Snwhitehornrm -rf $BSDINSTALL_TMPETC 57218799Snwhitehornmkdir $BSDINSTALL_TMPETC 58269653Sthompsamkdir -p $1 || error "mkdir failed for $1" 59218799Snwhitehorn 60220753Snwhitehorntest ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR 61218799Snwhitehorn 62220753Snwhitehornif [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then 63220753Snwhitehorn exec 3>&1 64220834Snwhitehorn BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) 65220753Snwhitehorn MIRROR_BUTTON=$? 66220753Snwhitehorn exec 3>&- 67269653Sthompsa test $MIRROR_BUTTON -eq 0 || error "No mirror selected" 68220753Snwhitehorn export BSDINSTALL_DISTSITE 69269653Sthompsa fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error "Could not download $BSDINSTALL_DISTSITE/MANIFEST" 70220753Snwhitehornfi 71220753Snwhitehorn 72220753Snwhitehornexport DISTRIBUTIONS="base.txz" 73220753Snwhitehornif [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 74220753Snwhitehorn DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base` 75220753Snwhitehorn 76220753Snwhitehorn exec 3>&1 77220753Snwhitehorn EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \ 78220753Snwhitehorn --backtitle "FreeBSD Installer" \ 79220753Snwhitehorn --title "Distribution Select" --nocancel --separate-output \ 80220753Snwhitehorn --checklist "Choose optional system components to install:" \ 81220753Snwhitehorn 0 0 0 \ 82220753Snwhitehorn 2>&1 1>&3) 83220753Snwhitehorn for dist in $EXTRA_DISTS; do 84220753Snwhitehorn export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 85220753Snwhitehorn done 86220753Snwhitehornfi 87220753Snwhitehorn 88218799SnwhitehornFETCH_DISTRIBUTIONS="" 89218799Snwhitehornfor dist in $DISTRIBUTIONS; do 90218799Snwhitehorn if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 91218799Snwhitehorn FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 92218799Snwhitehorn fi 93218799Snwhitehorndone 94220753SnwhitehornFETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space 95218799Snwhitehorn 96220753Snwhitehornif [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then 97220753Snwhitehorn exec 3>&1 98220753Snwhitehorn BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` 99220753Snwhitehorn MIRROR_BUTTON=$? 100220753Snwhitehorn exec 3>&- 101269653Sthompsa test $MIRROR_BUTTON -eq 0 || error "No mirror selected" 102220753Snwhitehorn export BSDINSTALL_DISTSITE 103220753Snwhitehornfi 104220753Snwhitehorn 105220753Snwhitehornif [ ! -z "$FETCH_DISTRIBUTIONS" ]; then 106269653Sthompsa bsdinstall distfetch || error "Failed to fetch distribution" 107218799Snwhitehornfi 108218799Snwhitehorn 109269653Sthompsabsdinstall checksum || error "Distribution checksum failed" 110269653Sthompsabsdinstall distextract || error "Distribution extract failed" 111269653Sthompsabsdinstall rootpass || error "Could not set root password" 112218799Snwhitehorn 113218799Snwhitehorntrap true SIGINT # This section is optional 114218799Snwhitehornbsdinstall services 115218799Snwhitehorn 116218799Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \ 117218799Snwhitehorn "Would you like to add users to the installed system now?" 0 0 && \ 118218799Snwhitehorn bsdinstall adduser 119218799Snwhitehorn 120218799Snwhitehorntrap error SIGINT # SIGINT is bad again 121269653Sthompsabsdinstall config || error "Failed to save config" 122220753Snwhitehorncp /etc/resolv.conf $1/etc 123220753Snwhitehorncp /etc/localtime $1/etc 124218799Snwhitehorn 125256338Sdesbsdinstall entropy 126256338Sdes 127257842Sdteskef_dprintf "Installation Completed at %s" "$(date)" 128287688Sdteskeexit $SUCCESS 129218799Snwhitehorn 130257842Sdteske################################################################################ 131257842Sdteske# END 132257842Sdteske################################################################################ 133