auto revision 219615
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/auto 219615 2011-03-13 17:15:31Z nwhitehorn $ 28218799Snwhitehorn 29218799Snwhitehornecho "Begun Installation at $(date)" > $BSDINSTALL_LOG 30218799Snwhitehorn 31218799Snwhitehornerror() { 32218799Snwhitehorn dialog --backtitle "FreeBSD Installer" --title "Abort" \ 33218799Snwhitehorn --no-label "Exit" --yes-label "Restart" --yesno \ 34218799Snwhitehorn "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 35218799Snwhitehorn if [ $? -ne 0 ]; then 36218799Snwhitehorn exit 37218799Snwhitehorn else 38218799Snwhitehorn test -f $PATH_FSTAB && bsdinstall umount 39218799Snwhitehorn exec $0 40218799Snwhitehorn fi 41218799Snwhitehorn} 42218799Snwhitehorn 43218799Snwhitehorn 44218799Snwhitehornrm -rf $BSDINSTALL_TMPETC 45218799Snwhitehornmkdir $BSDINSTALL_TMPETC 46218799Snwhitehorn 47218799Snwhitehorntrap true SIGINT # This section is optional 48218799Snwhitehornbsdinstall keymap 49218799Snwhitehorn 50218799Snwhitehorntrap error SIGINT # Catch cntrl-C here 51218799Snwhitehornbsdinstall hostname || error 52218799Snwhitehorn 53219615Snwhitehornexport DISTRIBUTIONS="base.txz kernel.txz" 54219615Snwhitehornif [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 55219615Snwhitehorn DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base` 56218947Snwhitehorn 57219615Snwhitehorn exec 3>&1 58219615Snwhitehorn EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \ 59219615Snwhitehorn --backtitle "FreeBSD Installer" \ 60219615Snwhitehorn --title "Distribution Select" --nocancel --separate-output \ 61219615Snwhitehorn --checklist "Choose optional system components to install:" \ 62219615Snwhitehorn 0 0 0 \ 63219615Snwhitehorn 2>&1 1>&3) 64219615Snwhitehorn for dist in $EXTRA_DISTS; do 65219615Snwhitehorn export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 66219615Snwhitehorn done 67219615Snwhitehornfi 68218947Snwhitehorn 69218799SnwhitehornFETCH_DISTRIBUTIONS="" 70218799Snwhitehornfor dist in $DISTRIBUTIONS; do 71218799Snwhitehorn if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 72218799Snwhitehorn FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 73218799Snwhitehorn fi 74218799Snwhitehorndone 75218799Snwhitehorn 76218799Snwhitehornif [ ! -z "$FETCH_DISTRIBUTIONS" -a ! -z $BSDINSTALL_CONFIGCURRENT ]; then 77218799Snwhitehorn dialog --backtitle "FreeBSD Installer" --title "Network Installation" --msgbox "No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0 78218799Snwhitehorn bsdinstall netconfig || error 79218799Snwhitehorn NETCONFIG_DONE=yes 80218799Snwhitehornfi 81218799Snwhitehorn 82218799Snwhitehornrm $PATH_FSTAB 83218799Snwhitehorntouch $PATH_FSTAB 84218799Snwhitehorn 85218799Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Partitioning" --extra-button \ 86218799Snwhitehorn --extra-label "Manual" --ok-label "Guided" --cancel-label "Shell" \ 87218799Snwhitehorn --yesno "Would you like to use the guided partitioning tool (recommended for beginners) or to set up partitions manually (experts)? You can also open a shell and set up partitions entirely by hand." 0 0 88218799Snwhitehorn 89218799Snwhitehorncase $? in 90218799Snwhitehorn0) # Guided 91218799Snwhitehorn bsdinstall autopart || error 92218799Snwhitehorn bsdinstall mount || error 93218799Snwhitehorn ;; 94218799Snwhitehorn1) # Shell 95218799Snwhitehorn clear 96218799Snwhitehorn echo "Use this shell to set up partitions for the new system. When finished, mount the system at $BSDINSTALL_CHROOT and place an fstab file for the new system at $PATH_FSTAB. Then type 'exit'. You can also enter the partition editor at any time by entering 'bsdinstall partedit'." 97218799Snwhitehorn sh 98218799Snwhitehorn ;; 99218799Snwhitehorn3) # Manual 100218799Snwhitehorn bsdinstall partedit || error 101218799Snwhitehorn bsdinstall mount || error 102218799Snwhitehorn ;; 103218799Snwhitehorn*) 104218799Snwhitehorn error 105218799Snwhitehorn ;; 106218799Snwhitehornesac 107218799Snwhitehorn 108218799Snwhitehornif [ ! -z "$FETCH_DISTRIBUTIONS" ]; then 109218799Snwhitehorn ALL_DISTRIBUTIONS="$DISTRIBUTIONS" 110218799Snwhitehorn 111218799Snwhitehorn # Download to a directory in the new system as scratch space 112219528Snwhitehorn BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" 113218799Snwhitehorn mkdir -p "$BSDINSTALL_FETCHDEST" || error 114218799Snwhitehorn 115218799Snwhitehorn export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" 116218799Snwhitehorn # Try to use any existing distfiles 117218799Snwhitehorn [ -d $BSDINSTALL_DISTDIR -a "$FETCH_DISTRIBUTIONS" != "$ALL_DISTRIBUTIONS" ] && mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" 118218799Snwhitehorn 119218799Snwhitehorn # Otherwise, fetch everything 120218799Snwhitehorn if [ $? -ne 0 ]; then 121218799Snwhitehorn export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 122218799Snwhitehorn export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" 123218799Snwhitehorn fi 124218799Snwhitehorn 125218799Snwhitehorn bsdinstall distfetch || error 126218799Snwhitehorn export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 127218799Snwhitehornfi 128218799Snwhitehorn 129219615Snwhitehornbsdinstall checksum || error 130218799Snwhitehornbsdinstall distextract || error 131218799Snwhitehornbsdinstall rootpass || error 132218799Snwhitehorn 133218799Snwhitehorntrap true SIGINT # This section is optional 134218799Snwhitehornif [ "$NETCONFIG_DONE" != yes ]; then 135218799Snwhitehorn bsdinstall netconfig # Don't check for errors -- the user may cancel 136218799Snwhitehornfi 137218799Snwhitehornbsdinstall time 138218799Snwhitehornbsdinstall services 139218799Snwhitehorn 140218799Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \ 141218799Snwhitehorn "Would you like to add users to the installed system now?" 0 0 && \ 142218799Snwhitehorn bsdinstall adduser 143218799Snwhitehorn 144218799Snwhitehornfinalconfig() { 145218799Snwhitehorn exec 3>&1 146218799Snwhitehorn REVISIT=$(dialog --backtitle "FreeBSD Installer" \ 147218799Snwhitehorn --title "Final Configuration" --no-cancel --menu \ 148218799Snwhitehorn "Setup of your FreeBSD system is nearly complete. You can now modify your configuration choices or apply more complex changes using a shell." 0 0 0 \ 149218799Snwhitehorn "Add User" "Add a user to the system" \ 150218799Snwhitehorn "Root Password" "Change root password" \ 151218799Snwhitehorn "Hostname" "Set system hostname" \ 152218799Snwhitehorn "Network" "Networking configuration" \ 153218799Snwhitehorn "Services" "Set daemons to run on startup" \ 154218799Snwhitehorn "Time Zone" "Set system timezone" \ 155218799Snwhitehorn "Shell" "Open a shell in the new system" \ 156218799Snwhitehorn "Reboot" "Apply configuration and reboot" 2>&1 1>&3) 157218799Snwhitehorn exec 3>&- 158218799Snwhitehorn 159218799Snwhitehorn case "$REVISIT" in 160218799Snwhitehorn "Add User") 161218799Snwhitehorn bsdinstall adduser 162218799Snwhitehorn finalconfig 163218799Snwhitehorn ;; 164218799Snwhitehorn "Root Password") 165218799Snwhitehorn bsdinstall rootpass 166218799Snwhitehorn finalconfig 167218799Snwhitehorn ;; 168218799Snwhitehorn "Hostname") 169218799Snwhitehorn bsdinstall hostname 170218799Snwhitehorn finalconfig 171218799Snwhitehorn ;; 172218799Snwhitehorn "Network") 173218799Snwhitehorn bsdinstall netconfig 174218799Snwhitehorn finalconfig 175218799Snwhitehorn ;; 176218799Snwhitehorn "Services") 177218799Snwhitehorn bsdinstall services 178218799Snwhitehorn finalconfig 179218799Snwhitehorn ;; 180218799Snwhitehorn "Time Zone") 181218799Snwhitehorn bsdinstall time 182218799Snwhitehorn finalconfig 183218799Snwhitehorn ;; 184218799Snwhitehorn "Shell") 185218799Snwhitehorn clear 186218799Snwhitehorn echo This shell is operating in a chroot in the new system. \ 187218799Snwhitehorn When finished making configuration changes, type \"exit\". 188218799Snwhitehorn chroot "$BSDINSTALL_CHROOT" /bin/sh 189218799Snwhitehorn # Don't hose local rc.conf changes 190218799Snwhitehorn cp $BSDINSTALL_CHROOT/etc/rc.conf $BSDINSTALL_TMPETC/rc.conf.manual 191218799Snwhitehorn finalconfig 192218799Snwhitehorn ;; 193218799Snwhitehorn esac 194218799Snwhitehorn} 195218799Snwhitehorn 196218799Snwhitehorn# Allow user to change his mind 197218799Snwhitehornfinalconfig 198218799Snwhitehorn 199218799Snwhitehorntrap error SIGINT # SIGINT is bad again 200218799Snwhitehornbsdinstall config || error 201218799Snwhitehorn 202218799Snwhitehornif [ ! -z "$BSDINSTALL_FETCHDEST" ]; then 203218799Snwhitehorn [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ 204218799Snwhitehorn umount "$BSDINSTALL_DISTDIR" 205218799Snwhitehorn rm -rf "$BSDINSTALL_FETCHDEST" 206218799Snwhitehornfi 207218799Snwhitehorn 208218799Snwhitehornecho "Installation Completed at $(date)" >> $BSDINSTALL_LOG 209218799Snwhitehorn 210