auto revision 241902
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 241902 2012-10-22 18:14:27Z dteske $ 28218799Snwhitehorn 29218799Snwhitehornecho "Begun Installation at $(date)" > $BSDINSTALL_LOG 30218799Snwhitehorn 31218799Snwhitehornerror() { 32220088Snwhitehorn test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR 33220088Snwhitehorn test -f $PATH_FSTAB && bsdinstall umount 34218799Snwhitehorn dialog --backtitle "FreeBSD Installer" --title "Abort" \ 35218799Snwhitehorn --no-label "Exit" --yes-label "Restart" --yesno \ 36218799Snwhitehorn "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 37218799Snwhitehorn if [ $? -ne 0 ]; then 38225637Snwhitehorn exit 1 39218799Snwhitehorn else 40218799Snwhitehorn exec $0 41218799Snwhitehorn fi 42218799Snwhitehorn} 43218799Snwhitehorn 44218799Snwhitehorn 45218799Snwhitehornrm -rf $BSDINSTALL_TMPETC 46218799Snwhitehornmkdir $BSDINSTALL_TMPETC 47218799Snwhitehorn 48218799Snwhitehorntrap true SIGINT # This section is optional 49218799Snwhitehornbsdinstall keymap 50218799Snwhitehorn 51218799Snwhitehorntrap error SIGINT # Catch cntrl-C here 52218799Snwhitehornbsdinstall hostname || error 53218799Snwhitehorn 54219615Snwhitehornexport DISTRIBUTIONS="base.txz kernel.txz" 55219615Snwhitehornif [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 56241902Sdteske DISTMENU=`awk '!/^(kernel|base)/{print $4,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST` 57218947Snwhitehorn 58219615Snwhitehorn exec 3>&1 59241902Sdteske EXTRA_DISTS=$( eval dialog \ 60241902Sdteske --backtitle \"FreeBSD Installer\" \ 61241902Sdteske --title \"Distribution Select\" --nocancel --separate-output \ 62241902Sdteske --checklist \"Choose optional system components to install:\" \ 63241902Sdteske 0 0 0 $DISTMENU \ 64241902Sdteske 2>&1 1>&3 ) 65219615Snwhitehorn for dist in $EXTRA_DISTS; do 66219615Snwhitehorn export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 67219615Snwhitehorn done 68219615Snwhitehornfi 69218947Snwhitehorn 70218799SnwhitehornFETCH_DISTRIBUTIONS="" 71218799Snwhitehornfor dist in $DISTRIBUTIONS; do 72218799Snwhitehorn if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 73218799Snwhitehorn FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 74218799Snwhitehorn fi 75218799Snwhitehorndone 76220080SnwhitehornFETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space 77218799Snwhitehorn 78220080Snwhitehornif [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then 79218799Snwhitehorn 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 80218799Snwhitehorn bsdinstall netconfig || error 81218799Snwhitehorn NETCONFIG_DONE=yes 82218799Snwhitehornfi 83218799Snwhitehorn 84220088Snwhitehornif [ -n "$FETCH_DISTRIBUTIONS" ]; then 85220080Snwhitehorn exec 3>&1 86220834Snwhitehorn BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) 87220080Snwhitehorn MIRROR_BUTTON=$? 88220080Snwhitehorn exec 3>&- 89220080Snwhitehorn test $MIRROR_BUTTON -eq 0 || error 90220080Snwhitehorn export BSDINSTALL_DISTSITE 91220080Snwhitehornfi 92220080Snwhitehorn 93218799Snwhitehornrm $PATH_FSTAB 94218799Snwhitehorntouch $PATH_FSTAB 95218799Snwhitehorn 96218799Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Partitioning" --extra-button \ 97218799Snwhitehorn --extra-label "Manual" --ok-label "Guided" --cancel-label "Shell" \ 98218799Snwhitehorn --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 99218799Snwhitehorn 100218799Snwhitehorncase $? in 101218799Snwhitehorn0) # Guided 102218799Snwhitehorn bsdinstall autopart || error 103218799Snwhitehorn bsdinstall mount || error 104218799Snwhitehorn ;; 105218799Snwhitehorn1) # Shell 106218799Snwhitehorn clear 107218799Snwhitehorn 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'." 108222425Snwhitehorn sh 2>&1 109218799Snwhitehorn ;; 110218799Snwhitehorn3) # Manual 111218799Snwhitehorn bsdinstall partedit || error 112218799Snwhitehorn bsdinstall mount || error 113218799Snwhitehorn ;; 114218799Snwhitehorn*) 115218799Snwhitehorn error 116218799Snwhitehorn ;; 117218799Snwhitehornesac 118218799Snwhitehorn 119218799Snwhitehornif [ ! -z "$FETCH_DISTRIBUTIONS" ]; then 120218799Snwhitehorn ALL_DISTRIBUTIONS="$DISTRIBUTIONS" 121218799Snwhitehorn 122218799Snwhitehorn # Download to a directory in the new system as scratch space 123219528Snwhitehorn BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" 124218799Snwhitehorn mkdir -p "$BSDINSTALL_FETCHDEST" || error 125218799Snwhitehorn 126218799Snwhitehorn export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" 127218799Snwhitehorn # Try to use any existing distfiles 128220088Snwhitehorn if [ -d $BSDINSTALL_DISTDIR ]; then 129220080Snwhitehorn DISTDIR_IS_UNIONFS=1 130223897Snwhitehorn mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" 131225637Snwhitehorn else 132225637Snwhitehorn export DISTRIBUTIONS="MANIFEST $ALL_DISTRIBUTIONS" 133218799Snwhitehorn export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" 134218799Snwhitehorn fi 135218799Snwhitehorn 136225637Snwhitehorn export FTP_PASSIVE_MODE=YES 137218799Snwhitehorn bsdinstall distfetch || error 138218799Snwhitehorn export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 139218799Snwhitehornfi 140218799Snwhitehorn 141219615Snwhitehornbsdinstall checksum || error 142218799Snwhitehornbsdinstall distextract || error 143218799Snwhitehornbsdinstall rootpass || error 144218799Snwhitehorn 145218799Snwhitehorntrap true SIGINT # This section is optional 146218799Snwhitehornif [ "$NETCONFIG_DONE" != yes ]; then 147218799Snwhitehorn bsdinstall netconfig # Don't check for errors -- the user may cancel 148218799Snwhitehornfi 149218799Snwhitehornbsdinstall time 150218799Snwhitehornbsdinstall services 151218799Snwhitehorn 152218799Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \ 153218799Snwhitehorn "Would you like to add users to the installed system now?" 0 0 && \ 154218799Snwhitehorn bsdinstall adduser 155218799Snwhitehorn 156218799Snwhitehornfinalconfig() { 157218799Snwhitehorn exec 3>&1 158218799Snwhitehorn REVISIT=$(dialog --backtitle "FreeBSD Installer" \ 159218799Snwhitehorn --title "Final Configuration" --no-cancel --menu \ 160228194Snwhitehorn "Setup of your FreeBSD system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \ 161226507Skensmith "Exit" "Apply configuration and exit installer" \ 162218799Snwhitehorn "Add User" "Add a user to the system" \ 163218799Snwhitehorn "Root Password" "Change root password" \ 164218799Snwhitehorn "Hostname" "Set system hostname" \ 165218799Snwhitehorn "Network" "Networking configuration" \ 166218799Snwhitehorn "Services" "Set daemons to run on startup" \ 167218799Snwhitehorn "Time Zone" "Set system timezone" \ 168228194Snwhitehorn "Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 1>&3) 169218799Snwhitehorn exec 3>&- 170218799Snwhitehorn 171218799Snwhitehorn case "$REVISIT" in 172218799Snwhitehorn "Add User") 173218799Snwhitehorn bsdinstall adduser 174218799Snwhitehorn finalconfig 175218799Snwhitehorn ;; 176218799Snwhitehorn "Root Password") 177218799Snwhitehorn bsdinstall rootpass 178218799Snwhitehorn finalconfig 179218799Snwhitehorn ;; 180218799Snwhitehorn "Hostname") 181218799Snwhitehorn bsdinstall hostname 182218799Snwhitehorn finalconfig 183218799Snwhitehorn ;; 184218799Snwhitehorn "Network") 185218799Snwhitehorn bsdinstall netconfig 186218799Snwhitehorn finalconfig 187218799Snwhitehorn ;; 188218799Snwhitehorn "Services") 189218799Snwhitehorn bsdinstall services 190218799Snwhitehorn finalconfig 191218799Snwhitehorn ;; 192218799Snwhitehorn "Time Zone") 193218799Snwhitehorn bsdinstall time 194218799Snwhitehorn finalconfig 195218799Snwhitehorn ;; 196223897Snwhitehorn "Handbook") 197223897Snwhitehorn bsdinstall docsinstall 198223897Snwhitehorn finalconfig 199223897Snwhitehorn ;; 200218799Snwhitehorn esac 201218799Snwhitehorn} 202218799Snwhitehorn 203218799Snwhitehorn# Allow user to change his mind 204218799Snwhitehornfinalconfig 205218799Snwhitehorn 206218799Snwhitehorntrap error SIGINT # SIGINT is bad again 207218799Snwhitehornbsdinstall config || error 208218799Snwhitehorn 209218799Snwhitehornif [ ! -z "$BSDINSTALL_FETCHDEST" ]; then 210218799Snwhitehorn [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ 211218799Snwhitehorn umount "$BSDINSTALL_DISTDIR" 212218799Snwhitehorn rm -rf "$BSDINSTALL_FETCHDEST" 213218799Snwhitehornfi 214218799Snwhitehorn 215228194Snwhitehorndialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \ 216228194Snwhitehorn --yesno "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0 217228194Snwhitehornif [ $? -eq 0 ]; then 218228194Snwhitehorn clear 219232531Snwhitehorn mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" 220228194Snwhitehorn echo This shell is operating in a chroot in the new system. \ 221228194Snwhitehorn When finished making configuration changes, type \"exit\". 222228194Snwhitehorn chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1 223228194Snwhitehornfi 224228194Snwhitehorn 225218799Snwhitehornecho "Installation Completed at $(date)" >> $BSDINSTALL_LOG 226218799Snwhitehorn 227