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#
| 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: head/usr.sbin/bsdinstall/scripts/auto 222607 2011-06-02 13:57:49Z nwhitehorn $
| 27# $FreeBSD: head/usr.sbin/bsdinstall/scripts/auto 223897 2011-07-09 23:01:54Z nwhitehorn $
|
28 29echo "Begun Installation at $(date)" > $BSDINSTALL_LOG 30 31error() { 32 test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR 33 test -f $PATH_FSTAB && bsdinstall umount 34 dialog --backtitle "FreeBSD Installer" --title "Abort" \ 35 --no-label "Exit" --yes-label "Restart" --yesno \ 36 "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 37 if [ $? -ne 0 ]; then 38 exit 39 else 40 exec $0 41 fi 42} 43 44 45rm -rf $BSDINSTALL_TMPETC 46mkdir $BSDINSTALL_TMPETC 47 48trap true SIGINT # This section is optional 49bsdinstall keymap 50 51trap error SIGINT # Catch cntrl-C here 52bsdinstall hostname || error 53 54export DISTRIBUTIONS="base.txz kernel.txz" 55if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 56 DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base` 57 58 exec 3>&1 59 EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \ 60 --backtitle "FreeBSD Installer" \ 61 --title "Distribution Select" --nocancel --separate-output \ 62 --checklist "Choose optional system components to install:" \ 63 0 0 0 \ 64 2>&1 1>&3) 65 for dist in $EXTRA_DISTS; do 66 export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 67 done 68fi 69 70FETCH_DISTRIBUTIONS="" 71for dist in $DISTRIBUTIONS; do 72 if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 73 FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 74 fi 75done 76FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space 77 78if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then 79 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 80 bsdinstall netconfig || error 81 NETCONFIG_DONE=yes 82fi 83 84if [ -n "$FETCH_DISTRIBUTIONS" ]; then 85 exec 3>&1 86 BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) 87 MIRROR_BUTTON=$? 88 exec 3>&- 89 test $MIRROR_BUTTON -eq 0 || error 90 export BSDINSTALL_DISTSITE 91fi 92 93rm $PATH_FSTAB 94touch $PATH_FSTAB 95 96dialog --backtitle "FreeBSD Installer" --title "Partitioning" --extra-button \ 97 --extra-label "Manual" --ok-label "Guided" --cancel-label "Shell" \ 98 --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 99 100case $? in 1010) # Guided 102 bsdinstall autopart || error 103 bsdinstall mount || error 104 ;; 1051) # Shell 106 clear 107 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'." 108 sh 2>&1 109 ;; 1103) # Manual 111 bsdinstall partedit || error 112 bsdinstall mount || error 113 ;; 114*) 115 error 116 ;; 117esac 118 119if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then 120 ALL_DISTRIBUTIONS="$DISTRIBUTIONS" 121 122 # Download to a directory in the new system as scratch space 123 BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" 124 mkdir -p "$BSDINSTALL_FETCHDEST" || error 125 126 export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" 127 # Try to use any existing distfiles 128 if [ -d $BSDINSTALL_DISTDIR ]; then 129 DISTDIR_IS_UNIONFS=1
| 28 29echo "Begun Installation at $(date)" > $BSDINSTALL_LOG 30 31error() { 32 test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR 33 test -f $PATH_FSTAB && bsdinstall umount 34 dialog --backtitle "FreeBSD Installer" --title "Abort" \ 35 --no-label "Exit" --yes-label "Restart" --yesno \ 36 "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 37 if [ $? -ne 0 ]; then 38 exit 39 else 40 exec $0 41 fi 42} 43 44 45rm -rf $BSDINSTALL_TMPETC 46mkdir $BSDINSTALL_TMPETC 47 48trap true SIGINT # This section is optional 49bsdinstall keymap 50 51trap error SIGINT # Catch cntrl-C here 52bsdinstall hostname || error 53 54export DISTRIBUTIONS="base.txz kernel.txz" 55if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 56 DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base` 57 58 exec 3>&1 59 EXTRA_DISTS=$(echo $DISTMENU | xargs dialog \ 60 --backtitle "FreeBSD Installer" \ 61 --title "Distribution Select" --nocancel --separate-output \ 62 --checklist "Choose optional system components to install:" \ 63 0 0 0 \ 64 2>&1 1>&3) 65 for dist in $EXTRA_DISTS; do 66 export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 67 done 68fi 69 70FETCH_DISTRIBUTIONS="" 71for dist in $DISTRIBUTIONS; do 72 if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 73 FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 74 fi 75done 76FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space 77 78if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then 79 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 80 bsdinstall netconfig || error 81 NETCONFIG_DONE=yes 82fi 83 84if [ -n "$FETCH_DISTRIBUTIONS" ]; then 85 exec 3>&1 86 BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) 87 MIRROR_BUTTON=$? 88 exec 3>&- 89 test $MIRROR_BUTTON -eq 0 || error 90 export BSDINSTALL_DISTSITE 91fi 92 93rm $PATH_FSTAB 94touch $PATH_FSTAB 95 96dialog --backtitle "FreeBSD Installer" --title "Partitioning" --extra-button \ 97 --extra-label "Manual" --ok-label "Guided" --cancel-label "Shell" \ 98 --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 99 100case $? in 1010) # Guided 102 bsdinstall autopart || error 103 bsdinstall mount || error 104 ;; 1051) # Shell 106 clear 107 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'." 108 sh 2>&1 109 ;; 1103) # Manual 111 bsdinstall partedit || error 112 bsdinstall mount || error 113 ;; 114*) 115 error 116 ;; 117esac 118 119if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then 120 ALL_DISTRIBUTIONS="$DISTRIBUTIONS" 121 122 # Download to a directory in the new system as scratch space 123 BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" 124 mkdir -p "$BSDINSTALL_FETCHDEST" || error 125 126 export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" 127 # Try to use any existing distfiles 128 if [ -d $BSDINSTALL_DISTDIR ]; then 129 DISTDIR_IS_UNIONFS=1
|
130 mount_unionfs "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR"
| 130 mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR"
|
131 fi 132 133 # Otherwise, fetch everything 134 if [ $? -ne 0 ]; then 135 export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 136 export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" 137 fi 138 139 bsdinstall distfetch || error 140 export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 141fi 142 143bsdinstall checksum || error 144bsdinstall distextract || error 145bsdinstall rootpass || error 146 147trap true SIGINT # This section is optional 148if [ "$NETCONFIG_DONE" != yes ]; then 149 bsdinstall netconfig # Don't check for errors -- the user may cancel 150fi 151bsdinstall time 152bsdinstall services 153 154dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \ 155 "Would you like to add users to the installed system now?" 0 0 && \ 156 bsdinstall adduser 157 158finalconfig() { 159 exec 3>&1 160 REVISIT=$(dialog --backtitle "FreeBSD Installer" \ 161 --title "Final Configuration" --no-cancel --menu \ 162 "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 \ 163 "Add User" "Add a user to the system" \ 164 "Root Password" "Change root password" \ 165 "Hostname" "Set system hostname" \ 166 "Network" "Networking configuration" \ 167 "Services" "Set daemons to run on startup" \ 168 "Time Zone" "Set system timezone" \
| 131 fi 132 133 # Otherwise, fetch everything 134 if [ $? -ne 0 ]; then 135 export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 136 export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" 137 fi 138 139 bsdinstall distfetch || error 140 export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" 141fi 142 143bsdinstall checksum || error 144bsdinstall distextract || error 145bsdinstall rootpass || error 146 147trap true SIGINT # This section is optional 148if [ "$NETCONFIG_DONE" != yes ]; then 149 bsdinstall netconfig # Don't check for errors -- the user may cancel 150fi 151bsdinstall time 152bsdinstall services 153 154dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \ 155 "Would you like to add users to the installed system now?" 0 0 && \ 156 bsdinstall adduser 157 158finalconfig() { 159 exec 3>&1 160 REVISIT=$(dialog --backtitle "FreeBSD Installer" \ 161 --title "Final Configuration" --no-cancel --menu \ 162 "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 \ 163 "Add User" "Add a user to the system" \ 164 "Root Password" "Change root password" \ 165 "Hostname" "Set system hostname" \ 166 "Network" "Networking configuration" \ 167 "Services" "Set daemons to run on startup" \ 168 "Time Zone" "Set system timezone" \
|
| 169 "Handbook" "Install FreeBSD Handbook (requires network)" \
|
169 "Shell" "Open a shell in the new system" \ 170 "Exit" "Apply configuration and exit installer" 2>&1 1>&3) 171 exec 3>&- 172 173 case "$REVISIT" in 174 "Add User") 175 bsdinstall adduser 176 finalconfig 177 ;; 178 "Root Password") 179 bsdinstall rootpass 180 finalconfig 181 ;; 182 "Hostname") 183 bsdinstall hostname 184 finalconfig 185 ;; 186 "Network") 187 bsdinstall netconfig 188 finalconfig 189 ;; 190 "Services") 191 bsdinstall services 192 finalconfig 193 ;; 194 "Time Zone") 195 bsdinstall time 196 finalconfig 197 ;;
| 170 "Shell" "Open a shell in the new system" \ 171 "Exit" "Apply configuration and exit installer" 2>&1 1>&3) 172 exec 3>&- 173 174 case "$REVISIT" in 175 "Add User") 176 bsdinstall adduser 177 finalconfig 178 ;; 179 "Root Password") 180 bsdinstall rootpass 181 finalconfig 182 ;; 183 "Hostname") 184 bsdinstall hostname 185 finalconfig 186 ;; 187 "Network") 188 bsdinstall netconfig 189 finalconfig 190 ;; 191 "Services") 192 bsdinstall services 193 finalconfig 194 ;; 195 "Time Zone") 196 bsdinstall time 197 finalconfig 198 ;;
|
| 199 "Handbook") 200 bsdinstall docsinstall 201 finalconfig 202 ;;
|
198 "Shell") 199 clear 200 echo This shell is operating in a chroot in the new system. \ 201 When finished making configuration changes, type \"exit\". 202 chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1 203 # Don't hose local rc.conf changes 204 cp $BSDINSTALL_CHROOT/etc/rc.conf $BSDINSTALL_TMPETC/rc.conf.manual 205 finalconfig 206 ;; 207 esac 208} 209 210# Allow user to change his mind 211finalconfig 212 213trap error SIGINT # SIGINT is bad again 214bsdinstall config || error 215 216if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then 217 [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ 218 umount "$BSDINSTALL_DISTDIR" 219 rm -rf "$BSDINSTALL_FETCHDEST" 220fi 221 222echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG 223
| 203 "Shell") 204 clear 205 echo This shell is operating in a chroot in the new system. \ 206 When finished making configuration changes, type \"exit\". 207 chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1 208 # Don't hose local rc.conf changes 209 cp $BSDINSTALL_CHROOT/etc/rc.conf $BSDINSTALL_TMPETC/rc.conf.manual 210 finalconfig 211 ;; 212 esac 213} 214 215# Allow user to change his mind 216finalconfig 217 218trap error SIGINT # SIGINT is bad again 219bsdinstall config || error 220 221if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then 222 [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ 223 umount "$BSDINSTALL_DISTDIR" 224 rm -rf "$BSDINSTALL_FETCHDEST" 225fi 226 227echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG 228
|