12118f387SNathan Whitehorn#!/bin/sh 22118f387SNathan Whitehorn#- 32118f387SNathan Whitehorn# Copyright (c) 2011 Nathan Whitehorn 4f0c98fdeSDevin Teske# Copyright (c) 2013-2018 Devin Teske 52118f387SNathan Whitehorn# All rights reserved. 62118f387SNathan Whitehorn# 72118f387SNathan Whitehorn# Redistribution and use in source and binary forms, with or without 82118f387SNathan Whitehorn# modification, are permitted provided that the following conditions 92118f387SNathan Whitehorn# are met: 102118f387SNathan Whitehorn# 1. Redistributions of source code must retain the above copyright 112118f387SNathan Whitehorn# notice, this list of conditions and the following disclaimer. 122118f387SNathan Whitehorn# 2. Redistributions in binary form must reproduce the above copyright 132118f387SNathan Whitehorn# notice, this list of conditions and the following disclaimer in the 142118f387SNathan Whitehorn# documentation and/or other materials provided with the distribution. 152118f387SNathan Whitehorn# 162118f387SNathan Whitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172118f387SNathan Whitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182118f387SNathan Whitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192118f387SNathan Whitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202118f387SNathan Whitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 212118f387SNathan Whitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222118f387SNathan Whitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232118f387SNathan Whitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242118f387SNathan Whitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252118f387SNathan Whitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262118f387SNathan Whitehorn# SUCH DAMAGE. 272118f387SNathan Whitehorn# 28bc4a673fSDevin Teske# 29bc4a673fSDevin Teske############################################################ INCLUDES 302118f387SNathan Whitehorn 31bc4a673fSDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 32bc4a673fSDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 337059fa6fSAllan Judef_include $BSDCFG_SHARE/dialog.subr 34bc4a673fSDevin Teske 35f0c98fdeSDevin Teske############################################################ GLOBALS 362118f387SNathan Whitehorn 37f0c98fdeSDevin Teske# 389de72af2SPierre Pronchery# List of environment variables that may be defined by the user, but modified 399de72af2SPierre Pronchery# during the installation process. They are then restored when restarting this 409de72af2SPierre Pronchery# script. 419de72af2SPierre Pronchery# 429de72af2SPierre Proncheryuser_env_vars="BSDINSTALL_DISTSITE DISTRIBUTIONS WORKAROUND_GPTACTIVE WORKAROUND_LENOVO ZFSBOOT_PARTITION_SCHEME" 439de72af2SPierre Pronchery 449de72af2SPierre Pronchery# 45f0c98fdeSDevin Teske# Strings that should be moved to an i18n file and loaded with f_include_lang() 46f0c98fdeSDevin Teske# 477059fa6fSAllan Judehline_arrows_tab_enter="Press arrows, TAB or ENTER" 48f0c98fdeSDevin Teskehline_arrows_tab_space_enter="Press arrows, TAB, SPACE or ENTER" 49f0c98fdeSDevin Teskemsg_abort="Abort" 50595373ddSBen Woodsmsg_an_installation_step_has_been_aborted="An installation step has been aborted. Would you like\nto restart the installation or exit the installer?" 51595373ddSBen Woodsmsg_auto_ufs="Auto (UFS)" 52595373ddSBen Woodsmsg_auto_ufs_desc="Guided UFS Disk Setup" 53595373ddSBen Woodsmsg_auto_ufs_help="Menu options help choose which disk to setup using UFS and standard partitions" 54595373ddSBen Woodsmsg_auto_zfs="Auto (ZFS)" 55595373ddSBen Woodsmsg_auto_zfs_desc="Guided Root-on-ZFS" 56595373ddSBen Woodsmsg_auto_zfs_help="To use ZFS with less than 8GB RAM, see https://wiki.freebsd.org/ZFSTuningGuide" 57f0c98fdeSDevin Teskemsg_exit="Exit" 58cc42ef53SBrad Davismsg_freebsd_installer="$OSNAME Installer" 59a7d5d8d9SAllan Judemsg_gpt_active_fix="Your hardware is known to have issues booting in CSM/Legacy/BIOS mode from GPT partitions that are not set active. Would you like the installer to apply this workaround for you?" 607059fa6fSAllan Judemsg_lenovo_fix="Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?" 61595373ddSBen Woodsmsg_manual="Manual" 62595373ddSBen Woodsmsg_manual_desc="Manual Disk Setup (experts)" 63595373ddSBen Woodsmsg_manual_help="Create customized partitions from menu options" 647059fa6fSAllan Judemsg_no="NO" 65f0c98fdeSDevin Teskemsg_restart="Restart" 66595373ddSBen Woodsmsg_shell="Shell" 67595373ddSBen Woodsmsg_shell_desc="Open a shell and partition by hand" 68595373ddSBen Woodsmsg_shell_help="Create customized partitions using command-line utilities" 697059fa6fSAllan Judemsg_yes="YES" 707059fa6fSAllan Jude 71f0c98fdeSDevin Teske############################################################ FUNCTIONS 72f0c98fdeSDevin Teske 73f0c98fdeSDevin Teske# error [$msg] 74f0c98fdeSDevin Teske# 75f0c98fdeSDevin Teske# Display generic error message when a script fails. An optional message 76*4ee348e2SJose Luis Duran# argument can precede the generic message. User is given the choice of 77f0c98fdeSDevin Teske# restarting the installer or exiting. 78f0c98fdeSDevin Teske# 79f0c98fdeSDevin Teskeerror() 80f0c98fdeSDevin Teske{ 81f0c98fdeSDevin Teske local title="$msg_abort" 82f0c98fdeSDevin Teske local btitle="$msg_freebsd_installer" 83f0c98fdeSDevin Teske local prompt="${1:+$1\n\n}$msg_an_installation_step_has_been_aborted" 84f0c98fdeSDevin Teske local hline="$hline_arrows_tab_space_enter" 85f0c98fdeSDevin Teske 86f0c98fdeSDevin Teske [ -f "$PATH_FSTAB" ] && bsdinstall umount 87f0c98fdeSDevin Teske 88f0c98fdeSDevin Teske local height width 89f0c98fdeSDevin Teske f_dialog_buttonbox_size height width \ 90f0c98fdeSDevin Teske "$title" "$btitle" "$prompt" "$hline" 91f0c98fdeSDevin Teske 92f0c98fdeSDevin Teske if $DIALOG \ 93f0c98fdeSDevin Teske --title "$title" \ 94f0c98fdeSDevin Teske --backtitle "$btitle" \ 95f0c98fdeSDevin Teske --hline "$hline" \ 96f0c98fdeSDevin Teske --no-label "$msg_exit" \ 97f0c98fdeSDevin Teske --yes-label "$msg_restart" \ 98f0c98fdeSDevin Teske --yesno "$prompt" $height $width 99f0c98fdeSDevin Teske then 1009de72af2SPierre Pronchery environment_restore 101f0c98fdeSDevin Teske exec $0 102f0c98fdeSDevin Teske # NOTREACHED 103f0c98fdeSDevin Teske fi 104f0c98fdeSDevin Teske exit 1 105f0c98fdeSDevin Teske} 106f0c98fdeSDevin Teske 1077059fa6fSAllan Jude# dialog_workaround 1087059fa6fSAllan Jude# 1097059fa6fSAllan Jude# Ask the user if they wish to apply a workaround 1107059fa6fSAllan Jude# 1117059fa6fSAllan Judedialog_workaround() 1127059fa6fSAllan Jude{ 1137059fa6fSAllan Jude local passed_msg="$1" 1147059fa6fSAllan Jude local title="$DIALOG_TITLE" 1157059fa6fSAllan Jude local btitle="$DIALOG_BACKTITLE" 1167059fa6fSAllan Jude local prompt # Calculated below 1177059fa6fSAllan Jude local hline="$hline_arrows_tab_enter" 1187059fa6fSAllan Jude 1197059fa6fSAllan Jude local height=8 width=50 prefix=" " 1207059fa6fSAllan Jude local plen=${#prefix} list= line= 1217059fa6fSAllan Jude local max_width=$(( $width - 3 - $plen )) 1227059fa6fSAllan Jude 1237059fa6fSAllan Jude local yes no defaultno extra_args format 1247059fa6fSAllan Jude if [ "$USE_XDIALOG" ]; then 1257059fa6fSAllan Jude yes=ok no=cancel defaultno=default-no 1267059fa6fSAllan Jude extra_args="--wrap --left" 1277059fa6fSAllan Jude format="$passed_msg" 1287059fa6fSAllan Jude else 1297059fa6fSAllan Jude yes=yes no=no defaultno=defaultno 1307059fa6fSAllan Jude extra_args="--cr-wrap" 1317059fa6fSAllan Jude format="$passed_msg" 1327059fa6fSAllan Jude fi 1337059fa6fSAllan Jude 1347059fa6fSAllan Jude # Add height for Xdialog(1) 1357059fa6fSAllan Jude [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 )) 1367059fa6fSAllan Jude 1377059fa6fSAllan Jude prompt=$( printf "$format" ) 1387059fa6fSAllan Jude f_dprintf "%s: Workaround prompt" "$0" 1397059fa6fSAllan Jude $DIALOG \ 1407059fa6fSAllan Jude --title "$title" \ 1417059fa6fSAllan Jude --backtitle "$btitle" \ 1427059fa6fSAllan Jude --hline "$hline" \ 1437059fa6fSAllan Jude --$yes-label "$msg_yes" \ 1447059fa6fSAllan Jude --$no-label "$msg_no" \ 1457059fa6fSAllan Jude $extra_args \ 1467059fa6fSAllan Jude --yesno "$prompt" $height $width 1477059fa6fSAllan Jude} 1487059fa6fSAllan Jude 1499de72af2SPierre Pronchery# environment_restore 1509de72af2SPierre Pronchery# 1519de72af2SPierre Pronchery# Restore a list of environment variables when this script is restarted. 1529de72af2SPierre Pronchery# 1539de72af2SPierre Proncheryenvironment_restore() 1549de72af2SPierre Pronchery{ 1559de72af2SPierre Pronchery for var in $user_env_vars; do 1569de72af2SPierre Pronchery eval "if [ -n \"\${ORIG_$var}\" -o -z \"\${ORIG_$var-z}\" ]; then $var=\${ORIG_$var}; else unset $var; fi" 1579de72af2SPierre Pronchery done 1589de72af2SPierre Pronchery} 1599de72af2SPierre Pronchery 1609de72af2SPierre Pronchery# environment_save 1619de72af2SPierre Pronchery# 1629de72af2SPierre Pronchery# Save any user-defined environment variable that may be modified during the 1639de72af2SPierre Pronchery# installation process. They are then restored when restarting this script. 1649de72af2SPierre Pronchery# 1659de72af2SPierre Proncheryenvironment_save() 1669de72af2SPierre Pronchery{ 1679de72af2SPierre Pronchery for var in $user_env_vars; do 1689de72af2SPierre Pronchery eval "if [ -n \"\${$var}\" -o -z \"\${$var-z}\" ]; then ORIG_$var=\${$var}; else unset ORIG_$var; fi" 1699de72af2SPierre Pronchery done 1709de72af2SPierre Pronchery} 1719de72af2SPierre Pronchery 172bc4a673fSDevin Teske############################################################ MAIN 173bc4a673fSDevin Teske 174bc4a673fSDevin Teskef_dprintf "Began Installation at %s" "$( date )" 1752118f387SNathan Whitehorn 1769de72af2SPierre Proncheryenvironment_save 1779de72af2SPierre Pronchery 1782118f387SNathan Whitehornrm -rf $BSDINSTALL_TMPETC 1792118f387SNathan Whitehornmkdir $BSDINSTALL_TMPETC 1802118f387SNathan Whitehorn 181494de51bSWarner Losh# Reset the ESP list 182494de51bSWarner Losh: > ${TMPDIR:-"/tmp"}/bsdinstall-esps 183494de51bSWarner Losh 184eb5884c5SEd Maste# With pkgbase, pkg OOM has been observed with QEMU-default 128 MiB memory size. 185eb5884c5SEd Maste# Ensure we have at least about 256 MiB (with an allowance for rounding etc.). 186eb5884c5SEd Mastephysmem=$(($(sysctl -n hw.physmem) / 1048576)) 187eb5884c5SEd Masteif [ $physmem -lt 200 ]; then 188eb5884c5SEd Maste bsddialog --backtitle "$OSNAME Installer" --title "Warning" \ 189eb5884c5SEd Maste --msgbox "Insufficient physical memory (${physmem} MiB) detected. At least 256 MiB is recommended. The installer or installed system may not function correctly." 0 0 190eb5884c5SEd Mastefi 191eb5884c5SEd Maste 19203d66186SBrad Davis[ -f /usr/libexec/bsdinstall/local.pre-everything ] && f_dprintf "Running local.pre-everything" && sh /usr/libexec/bsdinstall/local.pre-everything "$BSDINSTALL_CHROOT" 19303d66186SBrad Davis 1942118f387SNathan Whitehorntrap true SIGINT # This section is optional 19517f4ded5SBrad Davis[ -z "$BSDINSTALL_SKIP_KEYMAP" ] && bsdinstall keymap 1962118f387SNathan Whitehorn 1972118f387SNathan Whitehorntrap error SIGINT # Catch cntrl-C here 19817f4ded5SBrad Davisif [ -z "$BSDINSTALL_SKIP_HOSTNAME" ]; then bsdinstall hostname || error "Set hostname failed"; fi 1992118f387SNathan Whitehorn 2009134ed15SEd Masteif [ -f /usr/freebsd-packages/repos/FreeBSD-base-offline.conf ]; then 2019134ed15SEd Maste HAVE_BASE_PACKAGES=yes 2029134ed15SEd Maste PKGBASE_DEFAULT_BUTTON=--default-no 2039134ed15SEd Masteelse 2049134ed15SEd Maste unset HAVE_BASE_PACKAGES 2059134ed15SEd Maste unset PKGBASE_DEFAULT_BUTTON 2069134ed15SEd Mastefi 2079134ed15SEd Maste 20847c3158bSEd Masteif [ ! -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 20947c3158bSEd Maste PKGBASE=yes 21047c3158bSEd Masteelse 21134b43f4bSIsaac Freund bsddialog --backtitle "$OSNAME Installer" --title "Select Installation Type" \ 212abd94245SEd Maste --yes-label "Distribution Sets" --no-label "Packages (Tech Preview)" --yesno \ 2139134ed15SEd Maste $PKGBASE_DEFAULT_BUTTON \ 214abd94245SEd Maste "Would you like to install the base system using traditional distribution sets or packages (technology preview)?" 0 0 21534b43f4bSIsaac Freund if [ $? -eq 1 ]; then 21634b43f4bSIsaac Freund PKGBASE=yes 21734b43f4bSIsaac Freund fi 21847c3158bSEd Mastefi 21934b43f4bSIsaac Freund 22034b43f4bSIsaac Freundif [ "$PKGBASE" == yes ]; then 2219134ed15SEd Maste if [ "$HAVE_BASE_PACKAGES" == yes ]; then 2220a86a8acSIsaac Freund bsddialog --backtitle "$OSNAME Installer" --title "Network or Offline Installation" \ 2230a86a8acSIsaac Freund --yes-label "Network" --no-label "Offline (Limited Packages)" --yesno \ 2240a86a8acSIsaac Freund "Would you like to fetch packages from the internet or use the limited set of packages included in this installation media?" 0 0 2250a86a8acSIsaac Freund if [ $? -eq 1 ]; then 2260a86a8acSIsaac Freund export BSDINSTALL_PKG_REPOS_DIR=/usr/freebsd-packages/repos/ 2270a86a8acSIsaac Freund else 22834b43f4bSIsaac Freund bsdinstall netconfig || error 22934b43f4bSIsaac Freund NETCONFIG_DONE=yes 2300a86a8acSIsaac Freund fi 2310a86a8acSIsaac Freund else 2320a86a8acSIsaac Freund bsddialog --backtitle "$OSNAME Installer" --title "Network Installation" \ 2330a86a8acSIsaac Freund --msgbox "No base system packages are included in this installation media. The next few screens will allow you to configure networking." 0 0 2340a86a8acSIsaac Freund bsdinstall netconfig || error 2350a86a8acSIsaac Freund NETCONFIG_DONE=yes 2360a86a8acSIsaac Freund fi 23734b43f4bSIsaac Freundelse 2387143521fSJessica Clarke export DISTRIBUTIONS="${DISTRIBUTIONS:-base.txz kernel.txz}" 2397143521fSJessica Clarke if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then 2407143521fSJessica Clarke DISTMENU=`awk -F'\t' '!/^(kernel\.txz|base\.txz)/{print $1,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST` 2417143521fSJessica Clarke DISTMENU="$(echo ${DISTMENU} | sed -E 's/\.txz//g')" 2427143521fSJessica Clarke 2437143521fSJessica Clarke if [ -n "$DISTMENU" ]; then 244c0e249d3SLars Kellogg-Stedman exec 5>&1 2457143521fSJessica Clarke EXTRA_DISTS=$( eval bsddialog \ 2467143521fSJessica Clarke --backtitle \"$OSNAME Installer\" \ 2477143521fSJessica Clarke --title \"Distribution Select\" --nocancel --separate-output \ 2487143521fSJessica Clarke --checklist \"Choose optional system components to install:\" \ 2497143521fSJessica Clarke 0 0 0 $DISTMENU \ 2507143521fSJessica Clarke 2>&1 1>&5 ) 2517143521fSJessica Clarke for dist in $EXTRA_DISTS; do 2527143521fSJessica Clarke export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" 2537143521fSJessica Clarke done 2547143521fSJessica Clarke fi 2557143521fSJessica Clarke fi 2567143521fSJessica Clarke 2577143521fSJessica Clarke FETCH_DISTRIBUTIONS="" 2587143521fSJessica Clarke for dist in $DISTRIBUTIONS; do 2597143521fSJessica Clarke if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 2607143521fSJessica Clarke FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 2617143521fSJessica Clarke fi 2627143521fSJessica Clarke done 2637143521fSJessica Clarke 2647143521fSJessica Clarke if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then 2657143521fSJessica Clarke bsddialog --backtitle "$OSNAME Installer" --title "Network Installation" --msgbox "Some installation files were not 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 2667143521fSJessica Clarke bsdinstall netconfig || error 2677143521fSJessica Clarke NETCONFIG_DONE=yes 2682118f387SNathan Whitehorn fi 26934b43f4bSIsaac Freundfi 2702118f387SNathan Whitehorn 2712d5cf580SDevin Teskerm -f $PATH_FSTAB 2722118f387SNathan Whitehorntouch $PATH_FSTAB 2732118f387SNathan Whitehorn 27403d66186SBrad Davis[ -f /usr/libexec/bsdinstall/local.pre-partition ] && f_dprintf "Running local.pre-partition" && sh /usr/libexec/bsdinstall/local.pre-partition "$BSDINSTALL_CHROOT" 27503d66186SBrad Davis 2767059fa6fSAllan Jude# 2777059fa6fSAllan Jude# Try to detect known broken platforms and apply their workarounds 2787059fa6fSAllan Jude# 2797059fa6fSAllan Jude 2807059fa6fSAllan Judeif f_interactive; then 2817059fa6fSAllan Jude sys_maker=$( kenv -q smbios.system.maker ) 2827059fa6fSAllan Jude f_dprintf "smbios.system.maker=[%s]" "$sys_maker" 2837059fa6fSAllan Jude sys_model=$( kenv -q smbios.system.product ) 2847059fa6fSAllan Jude f_dprintf "smbios.system.product=[%s]" "$sys_model" 2857059fa6fSAllan Jude sys_version=$( kenv -q smbios.system.version ) 2867059fa6fSAllan Jude f_dprintf "smbios.system.version=[%s]" "$sys_version" 287a7d5d8d9SAllan Jude sys_mb_maker=$( kenv -q smbios.planar.maker ) 288a7d5d8d9SAllan Jude f_dprintf "smbios.planar.maker=[%s]" "$sys_mb_maker" 289a7d5d8d9SAllan Jude sys_mb_product=$( kenv -q smbios.planar.product ) 290a7d5d8d9SAllan Jude f_dprintf "smbios.planar.product=[%s]" "$sys_mb_product" 291a7d5d8d9SAllan Jude 292a7d5d8d9SAllan Jude # 293a7d5d8d9SAllan Jude # Laptop Models 294a7d5d8d9SAllan Jude # 2957059fa6fSAllan Jude case "$sys_maker" in 2967059fa6fSAllan Jude "LENOVO") 2977059fa6fSAllan Jude case "$sys_version" in 298229c92e7SAllan Jude "ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520"|"ThinkPad W520"|"ThinkPad X1") 2997059fa6fSAllan Jude dialog_workaround "$msg_lenovo_fix" 3007059fa6fSAllan Jude retval=$? 3017059fa6fSAllan Jude f_dprintf "lenovofix_prompt=[%s]" "$retval" 3027059fa6fSAllan Jude if [ $retval -eq $DIALOG_OK ]; then 3037059fa6fSAllan Jude export ZFSBOOT_PARTITION_SCHEME="GPT + Lenovo Fix" 3047059fa6fSAllan Jude export WORKAROUND_LENOVO=1 3057059fa6fSAllan Jude fi 3067059fa6fSAllan Jude ;; 3077059fa6fSAllan Jude esac 3087059fa6fSAllan Jude ;; 3097059fa6fSAllan Jude "Dell Inc.") 3107059fa6fSAllan Jude case "$sys_model" in 311e3026446SAllan Jude "Latitude E6330"|"Latitude E7440"|"Latitude E7240"|"Precision Tower 5810") 312a7d5d8d9SAllan Jude dialog_workaround "$msg_gpt_active_fix" 313a7d5d8d9SAllan Jude retval=$? 314a7d5d8d9SAllan Jude f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" 315a7d5d8d9SAllan Jude if [ $retval -eq $DIALOG_OK ]; then 316a7d5d8d9SAllan Jude export ZFSBOOT_PARTITION_SCHEME="GPT + Active" 317a7d5d8d9SAllan Jude export WORKAROUND_GPTACTIVE=1 318a7d5d8d9SAllan Jude fi 319a7d5d8d9SAllan Jude ;; 320a7d5d8d9SAllan Jude esac 321a7d5d8d9SAllan Jude ;; 3224c95e76aSAllan Jude "Hewlett-Packard") 3234c95e76aSAllan Jude case "$sys_model" in 3244c95e76aSAllan Jude "HP ProBook 4330s") 3254c95e76aSAllan Jude dialog_workaround "$msg_gpt_active_fix" 3264c95e76aSAllan Jude retval=$? 3274c95e76aSAllan Jude f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" 3284c95e76aSAllan Jude if [ $retval -eq $DIALOG_OK ]; then 3294c95e76aSAllan Jude export ZFSBOOT_PARTITION_SCHEME="GPT + Active" 3304c95e76aSAllan Jude export WORKAROUND_GPTACTIVE=1 3314c95e76aSAllan Jude fi 3324c95e76aSAllan Jude ;; 3334c95e76aSAllan Jude esac 3344c95e76aSAllan Jude ;; 335a7d5d8d9SAllan Jude esac 336a7d5d8d9SAllan Jude # 337a7d5d8d9SAllan Jude # Motherboard Models 338a7d5d8d9SAllan Jude # 339a7d5d8d9SAllan Jude case "$sys_mb_maker" in 340a7d5d8d9SAllan Jude "Intel Corporation") 341a7d5d8d9SAllan Jude case "$sys_mb_product" in 3424c95e76aSAllan Jude "DP965LT"|"D510MO") 3434c95e76aSAllan Jude dialog_workaround "$msg_gpt_active_fix" 3444c95e76aSAllan Jude retval=$? 3454c95e76aSAllan Jude f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" 3464c95e76aSAllan Jude if [ $retval -eq $DIALOG_OK ]; then 3474c95e76aSAllan Jude export ZFSBOOT_PARTITION_SCHEME="GPT + Active" 3484c95e76aSAllan Jude export WORKAROUND_GPTACTIVE=1 3494c95e76aSAllan Jude fi 3504c95e76aSAllan Jude ;; 3514c95e76aSAllan Jude esac 3524c95e76aSAllan Jude ;; 3534c95e76aSAllan Jude "Acer") 3544c95e76aSAllan Jude case "$sys_mb_product" in 3554c95e76aSAllan Jude "Veriton M6630G") 3567059fa6fSAllan Jude dialog_workaround "$msg_gpt_active_fix" 3577059fa6fSAllan Jude retval=$? 3587059fa6fSAllan Jude f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" 3597059fa6fSAllan Jude if [ $retval -eq $DIALOG_OK ]; then 3607059fa6fSAllan Jude export ZFSBOOT_PARTITION_SCHEME="GPT + Active" 3617059fa6fSAllan Jude export WORKAROUND_GPTACTIVE=1 3627059fa6fSAllan Jude fi 3637059fa6fSAllan Jude ;; 3647059fa6fSAllan Jude esac 3657059fa6fSAllan Jude ;; 3667059fa6fSAllan Jude esac 3677059fa6fSAllan Judefi 3687059fa6fSAllan Jude 369595373ddSBen WoodsPMODES=" 370595373ddSBen Woods '$msg_auto_ufs' '$msg_auto_ufs_desc' '$msg_auto_ufs_help' 371595373ddSBen Woods '$msg_manual' '$msg_manual_desc' '$msg_manual_help' 372595373ddSBen Woods '$msg_shell' '$msg_shell_desc' '$msg_shell_help' 373595373ddSBen Woods" # END-QUOTE 3742118f387SNathan Whitehorn 375cd88b886SDevin TeskeCURARCH=$( uname -m ) 376cd88b886SDevin Teskecase $CURARCH in 3777b08a307SMitchell Horne amd64|arm64|i386|riscv) # Booting ZFS Supported 378595373ddSBen Woods PMODES=" 379595373ddSBen Woods '$msg_auto_zfs' '$msg_auto_zfs_desc' '$msg_auto_zfs_help' 380595373ddSBen Woods $PMODES 381595373ddSBen Woods " # END-QUOTE 382cd88b886SDevin Teske ;; 383595373ddSBen Woods *) # Booting ZFS Unsupported 384cd88b886SDevin Teske ;; 385cd88b886SDevin Teskeesac 386cd88b886SDevin Teske 387c0e249d3SLars Kellogg-Stedmanexec 5>&1 38804b46577SAlfonso S. SicilianoPARTMODE=`echo $PMODES | xargs -o bsddialog --backtitle "$OSNAME Installer" \ 389cd88b886SDevin Teske --title "Partitioning" \ 390595373ddSBen Woods --item-help \ 391cd88b886SDevin Teske --menu "How would you like to partition your disk?" \ 392c0e249d3SLars Kellogg-Stedman 0 0 0 2>&1 1>&5` || exit 1 393c0e249d3SLars Kellogg-Stedmanexec 5>&- 394cd88b886SDevin Teske 395cd88b886SDevin Teskecase "$PARTMODE" in 396595373ddSBen Woods"$msg_auto_zfs") # ZFS 397d512033eSBen Woods bsdinstall zfsboot || error "ZFS setup failed" 398d512033eSBen Woods bsdinstall mount || error "Failed to mount filesystem" 399d512033eSBen Woods ;; 400595373ddSBen Woods"$msg_auto_ufs") # Guided UFS 4017041a67eSAndrew Thompson bsdinstall autopart || error "Partitioning error" 4027041a67eSAndrew Thompson bsdinstall mount || error "Failed to mount filesystem" 4032118f387SNathan Whitehorn ;; 404595373ddSBen Woods"$msg_shell") # Shell 4052118f387SNathan Whitehorn clear 4062118f387SNathan Whitehorn 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'." 407809685bcSNathan Whitehorn sh 2>&1 4082118f387SNathan Whitehorn ;; 409595373ddSBen Woods"$msg_manual") # Manual 410bc4a673fSDevin Teske if f_isset debugFile; then 411bc4a673fSDevin Teske # Give partedit the path to our logfile so it can append 4127041a67eSAndrew Thompson BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error "Partitioning error" 413bc4a673fSDevin Teske else 4147041a67eSAndrew Thompson bsdinstall partedit || error "Partitioning error" 415bc4a673fSDevin Teske fi 4167041a67eSAndrew Thompson bsdinstall mount || error "Failed to mount filesystem" 4172118f387SNathan Whitehorn ;; 4182118f387SNathan Whitehorn*) 4197041a67eSAndrew Thompson error "Unknown partitioning mode" 4202118f387SNathan Whitehorn ;; 4212118f387SNathan Whitehornesac 4222118f387SNathan Whitehorn 42303d66186SBrad Davis[ -f /usr/libexec/bsdinstall/local.pre-fetch ] && f_dprintf "Running local.pre-fetch" && sh /usr/libexec/bsdinstall/local.pre-fetch "$BSDINSTALL_CHROOT" 42403d66186SBrad Davis 42534b43f4bSIsaac Freundif [ "$PKGBASE" == yes ]; then 42634b43f4bSIsaac Freund bsdinstall pkgbase || error "Installation of base system packages failed" 42734b43f4bSIsaac Freundelse 42840923b0cSNathan Whitehorn if [ -n "$FETCH_DISTRIBUTIONS" ]; then 429c0e249d3SLars Kellogg-Stedman exec 5>&1 430c0e249d3SLars Kellogg-Stedman export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5) 43140923b0cSNathan Whitehorn FETCH_RESULT=$? 432c0e249d3SLars Kellogg-Stedman exec 5>&- 4332118f387SNathan Whitehorn 43440923b0cSNathan Whitehorn [ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions" 4352118f387SNathan Whitehorn fi 4367041a67eSAndrew Thompson bsdinstall checksum || error "Distribution checksum failed" 4377041a67eSAndrew Thompson bsdinstall distextract || error "Distribution extract failed" 43834b43f4bSIsaac Freundfi 4398befcf7bSNathan Whitehorn 4408befcf7bSNathan Whitehorn# Set up boot loader 4418befcf7bSNathan Whitehornbsdinstall bootconfig || error "Failed to configure bootloader" 4428befcf7bSNathan Whitehorn 44303d66186SBrad Davis[ -f /usr/libexec/bsdinstall/local.pre-configure ] && f_dprintf "Running local.pre-configure" && sh /usr/libexec/bsdinstall/local.pre-configure "$BSDINSTALL_CHROOT" 44403d66186SBrad Davis 4457041a67eSAndrew Thompsonbsdinstall rootpass || error "Could not set root password" 4462118f387SNathan Whitehorn 4472118f387SNathan Whitehorntrap true SIGINT # This section is optional 4482118f387SNathan Whitehornif [ "$NETCONFIG_DONE" != yes ]; then 4492118f387SNathan Whitehorn bsdinstall netconfig # Don't check for errors -- the user may cancel 4502118f387SNathan Whitehornfi 45117f4ded5SBrad Davis[ -z "$BSDINSTALL_SKIP_TIME" ] && bsdinstall time 45217f4ded5SBrad Davis[ -z "$BSDINSTALL_SKIP_SERVICES" ] && bsdinstall services 45317f4ded5SBrad Davis[ -z "$BSDINSTALL_SKIP_HARDENING" ] && bsdinstall hardening 454bbe2a1daSBjoern A. Zeeb[ -z "$BSDINSTALL_SKIP_FIRMWARE" ] && bsdinstall firmware 4552118f387SNathan Whitehorn 45604b46577SAlfonso S. Siciliano[ -z "$BSDINSTALL_SKIP_USERS" ] && bsddialog --backtitle "$OSNAME Installer" \ 45717f4ded5SBrad Davis --title "Add User Accounts" --yesno \ 4582118f387SNathan Whitehorn "Would you like to add users to the installed system now?" 0 0 && \ 4592118f387SNathan Whitehorn bsdinstall adduser 4602118f387SNathan Whitehorn 4612118f387SNathan Whitehorn# Allow user to change his mind 462a6d20207SPierre Pronchery[ -z "$BSDINSTALL_SKIP_FINALCONFIG" ] && bsdinstall finalconfig 4632118f387SNathan Whitehorn 4642118f387SNathan Whitehorntrap error SIGINT # SIGINT is bad again 4657041a67eSAndrew Thompsonbsdinstall config || error "Failed to save config" 4662118f387SNathan Whitehorn 4672118f387SNathan Whitehornif [ ! -z "$BSDINSTALL_FETCHDEST" ]; then 4682118f387SNathan Whitehorn rm -rf "$BSDINSTALL_FETCHDEST" 4692118f387SNathan Whitehornfi 4702118f387SNathan Whitehorn 47103d66186SBrad Davis[ -f /usr/libexec/bsdinstall/local.post-configure ] && f_dprintf "Running local.post-configure" && sh /usr/libexec/bsdinstall/local.post-configure "$BSDINSTALL_CHROOT" 47203d66186SBrad Davis 47317f4ded5SBrad Davisif [ -z "$BSDINSTALL_SKIP_MANUAL" ]; then 47404b46577SAlfonso S. Siciliano bsddialog --backtitle "$OSNAME Installer" --title "Manual Configuration" \ 47504b46577SAlfonso S. Siciliano --default-no --yesno \ 47644a25dd6SNathan Whitehorn "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 4776081c922SNathan Whitehorn if [ $? -eq 0 ]; then 4786081c922SNathan Whitehorn clear 4796081c922SNathan Whitehorn echo This shell is operating in a chroot in the new system. \ 4806081c922SNathan Whitehorn When finished making configuration changes, type \"exit\". 4815870d6a1SDag-Erling Smørgrav chroot "$BSDINSTALL_CHROOT" /bin/sh -l 2>&1 4826081c922SNathan Whitehorn fi 48317f4ded5SBrad Davisfi 4846081c922SNathan Whitehorn 485dfc23ba5SDag-Erling Smørgravbsdinstall entropy 486dfc23ba5SDag-Erling Smørgravbsdinstall umount 487dfc23ba5SDag-Erling Smørgrav 488bc4a673fSDevin Teskef_dprintf "Installation Completed at %s" "$( date )" 4892118f387SNathan Whitehorn 490bc4a673fSDevin Teske################################################################################ 491bc4a673fSDevin Teske# END 492bc4a673fSDevin Teske################################################################################ 493