diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index fd5b634696ae..95084f1bdcc3 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -1,456 +1,456 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # Copyright (c) 2013-2018 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_include $BSDCFG_SHARE/dialog.subr ############################################################ GLOBALS # # Strings that should be moved to an i18n file and loaded with f_include_lang() # hline_arrows_tab_enter="Press arrows, TAB or ENTER" hline_arrows_tab_space_enter="Press arrows, TAB, SPACE or ENTER" msg_abort="Abort" msg_an_installation_step_has_been_aborted="An installation step has been aborted. Would you like\nto restart the installation or exit the installer?" msg_auto_ufs="Auto (UFS)" msg_auto_ufs_desc="Guided UFS Disk Setup" msg_auto_ufs_help="Menu options help choose which disk to setup using UFS and standard partitions" msg_auto_zfs="Auto (ZFS)" msg_auto_zfs_desc="Guided Root-on-ZFS" msg_auto_zfs_help="To use ZFS with less than 8GB RAM, see https://wiki.freebsd.org/ZFSTuningGuide" msg_exit="Exit" msg_freebsd_installer="$OSNAME Installer" msg_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?" msg_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?" msg_manual="Manual" msg_manual_desc="Manual Disk Setup (experts)" msg_manual_help="Create customized partitions from menu options" msg_no="NO" msg_restart="Restart" msg_shell="Shell" msg_shell_desc="Open a shell and partition by hand" msg_shell_help="Create customized partitions using command-line utilities" msg_yes="YES" ############################################################ FUNCTIONS # error [$msg] # # Display generic error message when a script fails. An optional message # argument can preceed the generic message. User is given the choice of # restarting the installer or exiting. # error() { local title="$msg_abort" local btitle="$msg_freebsd_installer" local prompt="${1:+$1\n\n}$msg_an_installation_step_has_been_aborted" local hline="$hline_arrows_tab_space_enter" [ -f "$PATH_FSTAB" ] && bsdinstall umount local height width f_dialog_buttonbox_size height width \ "$title" "$btitle" "$prompt" "$hline" if $DIALOG \ --title "$title" \ --backtitle "$btitle" \ --hline "$hline" \ --no-label "$msg_exit" \ --yes-label "$msg_restart" \ --yesno "$prompt" $height $width then exec $0 # NOTREACHED fi exit 1 } # dialog_workaround # # Ask the user if they wish to apply a workaround # dialog_workaround() { local passed_msg="$1" local title="$DIALOG_TITLE" local btitle="$DIALOG_BACKTITLE" local prompt # Calculated below local hline="$hline_arrows_tab_enter" local height=8 width=50 prefix=" " local plen=${#prefix} list= line= local max_width=$(( $width - 3 - $plen )) local yes no defaultno extra_args format if [ "$USE_XDIALOG" ]; then yes=ok no=cancel defaultno=default-no extra_args="--wrap --left" format="$passed_msg" else yes=yes no=no defaultno=defaultno extra_args="--cr-wrap" format="$passed_msg" fi # Add height for Xdialog(1) [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 )) prompt=$( printf "$format" ) f_dprintf "%s: Workaround prompt" "$0" $DIALOG \ --title "$title" \ --backtitle "$btitle" \ --hline "$hline" \ --$yes-label "$msg_yes" \ --$no-label "$msg_no" \ $extra_args \ --yesno "$prompt" $height $width } ############################################################ MAIN f_dprintf "Began Installation at %s" "$( date )" rm -rf $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC [ -f /usr/libexec/bsdinstall/local.pre-everything ] && f_dprintf "Running local.pre-everything" && sh /usr/libexec/bsdinstall/local.pre-everything "$BSDINSTALL_CHROOT" trap true SIGINT # This section is optional [ -z "$BSDINSTALL_SKIP_KEYMAP" ] && bsdinstall keymap trap error SIGINT # Catch cntrl-C here if [ -z "$BSDINSTALL_SKIP_HOSTNAME" ]; then bsdinstall hostname || error "Set hostname failed"; fi export DISTRIBUTIONS="${DISTRIBUTIONS:-base.txz kernel.txz}" if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then DISTMENU=`awk -F'\t' '!/^(kernel\.txz|base\.txz)/{print $1,$5,$6}' $BSDINSTALL_DISTDIR/MANIFEST` DISTMENU="$(echo ${DISTMENU} | sed -E 's/\.txz//g')" if [ -n "$DISTMENU" ]; then - exec 3>&1 + exec 5>&1 EXTRA_DISTS=$( eval dialog \ --backtitle \"$OSNAME Installer\" \ --title \"Distribution Select\" --nocancel --separate-output \ --checklist \"Choose optional system components to install:\" \ 0 0 0 $DISTMENU \ - 2>&1 1>&3 ) + 2>&1 1>&5 ) for dist in $EXTRA_DISTS; do export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" done fi fi FETCH_DISTRIBUTIONS="" for dist in $DISTRIBUTIONS; do if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" fi done if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then dialog --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 bsdinstall netconfig || error NETCONFIG_DONE=yes fi rm -f $PATH_FSTAB touch $PATH_FSTAB [ -f /usr/libexec/bsdinstall/local.pre-partition ] && f_dprintf "Running local.pre-partition" && sh /usr/libexec/bsdinstall/local.pre-partition "$BSDINSTALL_CHROOT" # # Try to detect known broken platforms and apply their workarounds # if f_interactive; then sys_maker=$( kenv -q smbios.system.maker ) f_dprintf "smbios.system.maker=[%s]" "$sys_maker" sys_model=$( kenv -q smbios.system.product ) f_dprintf "smbios.system.product=[%s]" "$sys_model" sys_version=$( kenv -q smbios.system.version ) f_dprintf "smbios.system.version=[%s]" "$sys_version" sys_mb_maker=$( kenv -q smbios.planar.maker ) f_dprintf "smbios.planar.maker=[%s]" "$sys_mb_maker" sys_mb_product=$( kenv -q smbios.planar.product ) f_dprintf "smbios.planar.product=[%s]" "$sys_mb_product" # # Laptop Models # case "$sys_maker" in "LENOVO") case "$sys_version" in "ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520"|"ThinkPad W520"|"ThinkPad X1") dialog_workaround "$msg_lenovo_fix" retval=$? f_dprintf "lenovofix_prompt=[%s]" "$retval" if [ $retval -eq $DIALOG_OK ]; then export ZFSBOOT_PARTITION_SCHEME="GPT + Lenovo Fix" export WORKAROUND_LENOVO=1 fi ;; esac ;; "Dell Inc.") case "$sys_model" in "Latitude E6330"|"Latitude E7440"|"Latitude E7240"|"Precision Tower 5810") dialog_workaround "$msg_gpt_active_fix" retval=$? f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" if [ $retval -eq $DIALOG_OK ]; then export ZFSBOOT_PARTITION_SCHEME="GPT + Active" export WORKAROUND_GPTACTIVE=1 fi ;; esac ;; "Hewlett-Packard") case "$sys_model" in "HP ProBook 4330s") dialog_workaround "$msg_gpt_active_fix" retval=$? f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" if [ $retval -eq $DIALOG_OK ]; then export ZFSBOOT_PARTITION_SCHEME="GPT + Active" export WORKAROUND_GPTACTIVE=1 fi ;; esac ;; esac # # Motherboard Models # case "$sys_mb_maker" in "Intel Corporation") case "$sys_mb_product" in "DP965LT"|"D510MO") dialog_workaround "$msg_gpt_active_fix" retval=$? f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" if [ $retval -eq $DIALOG_OK ]; then export ZFSBOOT_PARTITION_SCHEME="GPT + Active" export WORKAROUND_GPTACTIVE=1 fi ;; esac ;; "Acer") case "$sys_mb_product" in "Veriton M6630G") dialog_workaround "$msg_gpt_active_fix" retval=$? f_dprintf "gpt_active_fix_prompt=[%s]" "$retval" if [ $retval -eq $DIALOG_OK ]; then export ZFSBOOT_PARTITION_SCHEME="GPT + Active" export WORKAROUND_GPTACTIVE=1 fi ;; esac ;; esac fi PMODES=" '$msg_auto_ufs' '$msg_auto_ufs_desc' '$msg_auto_ufs_help' '$msg_manual' '$msg_manual_desc' '$msg_manual_help' '$msg_shell' '$msg_shell_desc' '$msg_shell_help' " # END-QUOTE CURARCH=$( uname -m ) case $CURARCH in amd64|arm64|i386|riscv) # Booting ZFS Supported PMODES=" '$msg_auto_zfs' '$msg_auto_zfs_desc' '$msg_auto_zfs_help' $PMODES " # END-QUOTE ;; *) # Booting ZFS Unsupported ;; esac -exec 3>&1 +exec 5>&1 PARTMODE=`echo $PMODES | xargs dialog --backtitle "$OSNAME Installer" \ --title "Partitioning" \ --item-help \ --menu "How would you like to partition your disk?" \ - 0 0 0 2>&1 1>&3` || exit 1 -exec 3>&- + 0 0 0 2>&1 1>&5` || exit 1 +exec 5>&- case "$PARTMODE" in "$msg_auto_zfs") # ZFS bsdinstall zfsboot || error "ZFS setup failed" bsdinstall mount || error "Failed to mount filesystem" ;; "$msg_auto_ufs") # Guided UFS bsdinstall autopart || error "Partitioning error" bsdinstall mount || error "Failed to mount filesystem" ;; "$msg_shell") # Shell clear 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'." sh 2>&1 ;; "$msg_manual") # Manual if f_isset debugFile; then # Give partedit the path to our logfile so it can append BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error "Partitioning error" else bsdinstall partedit || error "Partitioning error" fi bsdinstall mount || error "Failed to mount filesystem" ;; *) error "Unknown partitioning mode" ;; esac [ -f /usr/libexec/bsdinstall/local.pre-fetch ] && f_dprintf "Running local.pre-fetch" && sh /usr/libexec/bsdinstall/local.pre-fetch "$BSDINSTALL_CHROOT" if [ -n "$FETCH_DISTRIBUTIONS" ]; then - exec 3>&1 - export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3) + exec 5>&1 + export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5) FETCH_RESULT=$? - exec 3>&- + exec 5>&- [ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions" fi bsdinstall checksum || error "Distribution checksum failed" bsdinstall distextract || error "Distribution extract failed" # Set up boot loader bsdinstall bootconfig || error "Failed to configure bootloader" [ -f /usr/libexec/bsdinstall/local.pre-configure ] && f_dprintf "Running local.pre-configure" && sh /usr/libexec/bsdinstall/local.pre-configure "$BSDINSTALL_CHROOT" bsdinstall rootpass || error "Could not set root password" trap true SIGINT # This section is optional if [ "$NETCONFIG_DONE" != yes ]; then bsdinstall netconfig # Don't check for errors -- the user may cancel fi [ -z "$BSDINSTALL_SKIP_TIME" ] && bsdinstall time [ -z "$BSDINSTALL_SKIP_SERVICES" ] && bsdinstall services [ -z "$BSDINSTALL_SKIP_HARDENING" ] && bsdinstall hardening [ -z "$BSDINSTALL_SKIP_USERS" ] && dialog --backtitle "$OSNAME Installer" \ --title "Add User Accounts" --yesno \ "Would you like to add users to the installed system now?" 0 0 && \ bsdinstall adduser finalconfig() { - exec 3>&1 + exec 5>&1 REVISIT=$(dialog --backtitle "$OSNAME Installer" \ --title "Final Configuration" --no-cancel --menu \ "Setup of your $OSNAME 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 \ "Exit" "Apply configuration and exit installer" \ "Add User" "Add a user to the system" \ "Root Password" "Change root password" \ "Hostname" "Set system hostname" \ "Network" "Networking configuration" \ "Services" "Set daemons to run on startup" \ "System Hardening" "Set security options" \ "Time Zone" "Set system timezone" \ - "Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&3) - exec 3>&- + "Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&5) + exec 5>&- case "$REVISIT" in "Add User") bsdinstall adduser finalconfig ;; "Root Password") bsdinstall rootpass finalconfig ;; "Hostname") bsdinstall hostname finalconfig ;; "Network") bsdinstall netconfig finalconfig ;; "Services") bsdinstall services finalconfig ;; "System Hardening") bsdinstall hardening finalconfig ;; "Time Zone") bsdinstall time finalconfig ;; "Handbook") bsdinstall docsinstall finalconfig ;; esac } # Allow user to change his mind [ -z "$BSDINSTALL_SKIP_FINALCONFIG" ] && finalconfig trap error SIGINT # SIGINT is bad again bsdinstall config || error "Failed to save config" if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then rm -rf "$BSDINSTALL_FETCHDEST" fi [ -f /usr/libexec/bsdinstall/local.post-configure ] && f_dprintf "Running local.post-configure" && sh /usr/libexec/bsdinstall/local.post-configure "$BSDINSTALL_CHROOT" if [ -z "$BSDINSTALL_SKIP_MANUAL" ]; then dialog --backtitle "$OSNAME Installer" --title "Manual Configuration" \ --default-button no --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 if [ $? -eq 0 ]; then clear echo This shell is operating in a chroot in the new system. \ When finished making configuration changes, type \"exit\". chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1 fi fi bsdinstall entropy bsdinstall umount f_dprintf "Installation Completed at %s" "$( date )" ################################################################################ # END ################################################################################ diff --git a/usr.sbin/bsdinstall/scripts/fetchmissingdists b/usr.sbin/bsdinstall/scripts/fetchmissingdists index a1ce9e4e0ca5..d37acc96b92c 100644 --- a/usr.sbin/bsdinstall/scripts/fetchmissingdists +++ b/usr.sbin/bsdinstall/scripts/fetchmissingdists @@ -1,134 +1,134 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # Copyright (c) 2013-2018 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 error() { bsddialog --backtitle "$OSNAME Installer" --title "Error" --msgbox "$1" 0 0 exit 1 } FETCH_DISTRIBUTIONS="" LOCAL_DISTRIBUTIONS="" for dist in $DISTRIBUTIONS; do if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" else LOCAL_DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS $dist" fi done LOCAL_DISTRIBUTIONS=`echo $LOCAL_DISTRIBUTIONS` # Trim white space FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space if [ -z "$FETCH_DISTRIBUTIONS" ]; then echo $BSDINSTALL_DISTDIR >&2 exit 0 fi ALL_DISTRIBUTIONS="$DISTRIBUTIONS" WANT_DEBUG= # Download to a directory in the new system as scratch space BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST" if [ -z "$BSDINSTALL_DISTSITE" ]; then - exec 3>&1 - BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) + exec 5>&1 + BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5) MIRROR_BUTTON=$? - exec 3>&- + exec 5>&- test $MIRROR_BUTTON -eq 0 || error "No mirror selected" export BSDINSTALL_DISTSITE fi BSDINSTALL_DISTDIR_ORIG="$BSDINSTALL_DISTDIR" export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" export FTP_PASSIVE_MODE=YES if [ -f "$BSDINSTALL_DISTDIR_ORIG/MANIFEST" ]; then cp "$BSDINSTALL_DISTDIR_ORIG/MANIFEST" "$BSDINSTALL_DISTDIR/MANIFEST" VERIFY_MANIFEST_SIG=0 else FETCH_DISTRIBUTIONS="MANIFEST $FETCH_DISTRIBUTIONS" VERIFY_MANIFEST_SIG=1 # XXX actually verify signature on manifest bsddialog --backtitle "$OSNAME Installer" --title "Warning" --msgbox "Manifest not found on local disk and will be fetched from an unverified source. This is a potential security risk. If you do not wish to proceed, press control-C now." 0 0 fi if [ ! -z "$LOCAL_DISTRIBUTIONS" ]; then # Copy local stuff first env DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS" \ BSDINSTALL_DISTSITE="file://$BSDINSTALL_DISTDIR_ORIG" \ bsdinstall distfetch || \ error "Failed to fetch distribution from local media" fi export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" # Iterate through the distribution list and set a flag if debugging # distributions have been selected. for _DISTRIBUTION in $DISTRIBUTIONS; do case $_DISTRIBUTION in *-dbg.*) [ -e $BSDINSTALL_DISTDIR/$_DISTRIBUTION ] \ && continue WANT_DEBUG=1 DEBUG_LIST="\n$DEBUG_LIST\n$_DISTRIBUTION" ;; *) ;; esac done # Fetch the distributions. bsdinstall distfetch rc=$? if [ $rc -ne 0 ]; then # If unable to fetch the remote distributions, recommend # deselecting the debugging distributions, and retrying the # installation, since failure to fetch *-dbg.txz should not # be considered a fatal installation error. msg="Failed to fetch remote distribution" if [ ! -z "$WANT_DEBUG" ]; then # Trim leading and trailing newlines. DEBUG_LIST="${DEBUG_LIST%%\n}" DEBUG_LIST="${DEBUG_LIST##\n}" msg="$msg\n\nPlease deselect the following distributions" msg="$msg and retry the installation:" msg="$msg\n$DEBUG_LIST" fi error "$msg" fi echo $BSDINSTALL_DISTDIR >&2 diff --git a/usr.sbin/bsdinstall/scripts/hardening b/usr.sbin/bsdinstall/scripts/hardening index b9e259ff1a13..a77fcdeaf540 100755 --- a/usr.sbin/bsdinstall/scripts/hardening +++ b/usr.sbin/bsdinstall/scripts/hardening @@ -1,93 +1,93 @@ #!/bin/sh #- # Copyright (c) 2016 Bartek Rutkowski # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 : ${BSDDIALOG_OK=0} echo -n > $BSDINSTALL_TMPETC/rc.conf.hardening echo -n > $BSDINSTALL_TMPETC/sysctl.conf.hardening echo -n > $BSDINSTALL_TMPBOOT/loader.conf.hardening -exec 3>&1 +exec 5>&1 FEATURES=$( bsddialog --backtitle "$OSNAME Installer" \ --title "System Hardening" --nocancel --separate-output \ --checklist "Choose system security hardening options:" \ 0 0 0 \ "0 hide_uids" "Hide processes running as other users" ${hide_uids:-off} \ "1 hide_gids" "Hide processes running as other groups" ${hide_gids:-off} \ "2 hide_jail" "Hide processes running in jails" ${hide_jail:-off} \ "3 read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-off} \ "4 proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-off} \ "5 random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \ "6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \ "7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \ "8 secure_console" "Enable console password prompt" ${secure_console:-off} \ "9 disable_ddtrace" "Disallow DTrace destructive-mode" ${disable_ddtrace:-off} \ -2>&1 1>&3 ) +2>&1 1>&5 ) retval=$? -exec 3>&- +exec 5>&- if [ $retval -ne $BSDDIALOG_OK ]; then exit 1 fi for feature in $FEATURES; do case "$feature" in hide_uids) echo security.bsd.see_other_uids=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening ;; hide_gids) echo security.bsd.see_other_gids=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening ;; hide_jail) echo security.bsd.see_jail_proc=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening ;; read_msgbuf) echo security.bsd.unprivileged_read_msgbuf=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening ;; proc_debug) echo security.bsd.unprivileged_proc_debug=0 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening ;; random_pid) echo kern.randompid=1 >> $BSDINSTALL_TMPETC/sysctl.conf.hardening ;; clear_tmp) echo 'clear_tmp_enable="YES"' >> $BSDINSTALL_TMPETC/rc.conf.hardening ;; disable_syslogd) echo 'syslogd_flags="-ss"' >> $BSDINSTALL_TMPETC/rc.conf.hardening ;; secure_console) sed "s/unknown off secure/unknown off insecure/g" $BSDINSTALL_CHROOT/etc/ttys > $BSDINSTALL_TMPETC/ttys.hardening ;; disable_ddtrace) echo 'security.bsd.allow_destructive_dtrace=0' >> $BSDINSTALL_TMPBOOT/loader.conf.hardening ;; esac done diff --git a/usr.sbin/bsdinstall/scripts/jail b/usr.sbin/bsdinstall/scripts/jail index e5822087e97b..ab095f44ba39 100755 --- a/usr.sbin/bsdinstall/scripts/jail +++ b/usr.sbin/bsdinstall/scripts/jail @@ -1,160 +1,160 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # Copyright (c) 2013-2015 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 ############################################################ MAIN : ${BSDDIALOG_OK=0} f_dprintf "Began Installation at %s" "$( date )" export BSDINSTALL_CHROOT=$1 error() { local msg if [ -n "$1" ]; then msg="$1\n\n" fi bsddialog --backtitle "$OSNAME Installer" --title "Abort" \ --no-label "Exit" --yes-label "Restart" --yesno \ "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 if [ $? -ne $BSDDIALOG_OK ]; then exit else exec $0 $BSDINSTALL_CHROOT fi } rm -rf $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC mkdir -p $1 || error "mkdir failed for $1" if [ -n "$SCRIPT" ] then split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript- . $TMPDIR/bsdinstall-installscript-aa fi test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then - exec 3>&1 - BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) + exec 5>&1 + BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5) MIRROR_BUTTON=$? - exec 3>&- + exec 5>&- test $MIRROR_BUTTON -eq 0 || error "No mirror selected" export BSDINSTALL_DISTSITE fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error "Could not download $BSDINSTALL_DISTSITE/MANIFEST" fi : ${DISTRIBUTIONS="base.txz"}; export DISTRIBUTIONS if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then DISTMENU=`cut -f 4,5,6 $BSDINSTALL_DISTDIR/MANIFEST | grep -v -e ^kernel -e ^base` if [ ! "$nonInteractive" == "YES" ] then - exec 3>&1 + exec 5>&1 EXTRA_DISTS=$(echo $DISTMENU | xargs -o bsddialog \ --backtitle "$OSNAME Installer" \ --title "Distribution Select" --no-cancel --separate-output \ --checklist "Choose optional system components to install:" \ 0 0 0 \ - 2>&1 1>&3) + 2>&1 1>&5) for dist in $EXTRA_DISTS; do export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" done fi fi FETCH_DISTRIBUTIONS="" for dist in $DISTRIBUTIONS; do if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" fi done FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then - exec 3>&1 - BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) + exec 5>&1 + BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5) MIRROR_BUTTON=$? - exec 3>&- + exec 5>&- test $MIRROR_BUTTON -eq 0 || error "No mirror selected" export BSDINSTALL_DISTSITE fi if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then bsdinstall distfetch || error "Failed to fetch distribution" fi bsdinstall checksum || error "Distribution checksum failed" bsdinstall distextract || error "Distribution extract failed" if [ ! "$nonInteractive" == "YES" ] then bsdinstall rootpass || error "Could not set root password" fi trap true SIGINT # This section is optional if [ ! "$nonInteractive" == "YES" ] then bsdinstall services bsddialog --backtitle "$OSNAME Installer" --title "Add User Accounts" --yesno \ "Would you like to add users to the installed system now?" 0 0 && \ bsdinstall adduser fi trap error SIGINT # SIGINT is bad again bsdinstall config || error "Failed to save config" cp /etc/resolv.conf $1/etc cp /etc/localtime $1/etc cp /var/db/zoneinfo $1/var/db # Run post-install script if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript chmod a+x $BSDINSTALL_CHROOT/tmp/installscript mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 umount "$BSDINSTALL_CHROOT/dev" rm $BSDINSTALL_CHROOT/tmp/installscript fi bsdinstall entropy f_dprintf "Installation Completed at %s" "$(date)" exit $SUCCESS ################################################################################ # END ################################################################################ diff --git a/usr.sbin/bsdinstall/scripts/mirrorselect b/usr.sbin/bsdinstall/scripts/mirrorselect index 82a726c009b6..901f816206ba 100755 --- a/usr.sbin/bsdinstall/scripts/mirrorselect +++ b/usr.sbin/bsdinstall/scripts/mirrorselect @@ -1,128 +1,128 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 : ${BSDDIALOG_OK=0} : ${BSDDIALOG_CANCEL=1} : ${BSDDIALOG_HELP=2} : ${BSDDIALOG_EXTRA=3} : ${BSDDIALOG_ESC=5} : ${BSDDIALOG_ERROR=255} -exec 3>&1 +exec 5>&1 MIRROR=`bsddialog --backtitle "$OSNAME Installer" \ --title "Mirror Selection" --extra-button --extra-label "Other" \ --menu "Please select the best suitable site for you or \"other\" if you want to specify a different choice. The \"Main Site\" directs users to the nearest project managed mirror via GeoDNS (they carry the full range of possible distributions and support both IPv4 and IPv6). All other sites are known as \"Community Mirrors\"; not every site listed here carries more than the base distribution kits. Select a site!" \ 0 0 16 \ ftp://download.freebsd.org "Main Site (GeoDNS)"\ http://ftp.au.freebsd.org "Australia - IPv6"\ ftp://ftp3.au.freebsd.org "Australia #3"\ ftp://ftp.at.freebsd.org "Austria - IPv6"\ ftp://ftp2.br.freebsd.org "Brazil #2"\ ftp://ftp3.br.freebsd.org "Brazil #3"\ ftp://ftp.bg.freebsd.org "Bulgaria - IPv6"\ ftp://ftp.cz.freebsd.org "Czech Republic - IPv6"\ ftp://ftp.dk.freebsd.org "Denmark - IPv6"\ ftp://ftp.fi.freebsd.org "Finland"\ ftp://ftp.fr.freebsd.org "France - IPv6"\ ftp://ftp3.fr.freebsd.org "France #3"\ ftp://ftp6.fr.freebsd.org "France #6"\ ftp://ftp.de.freebsd.org "Germany - IPv6"\ ftp://ftp1.de.freebsd.org "Germany #1 - IPv6"\ ftp://ftp2.de.freebsd.org "Germany #2 - IPv6"\ ftp://ftp5.de.freebsd.org "Germany #5 - IPv6"\ ftp://ftp7.de.freebsd.org "Germany #7 - IPv6"\ ftp://ftp.gr.freebsd.org "Greece - IPv6"\ ftp://ftp2.gr.freebsd.org "Greece #2 - IPv6"\ ftp://ftp.jp.freebsd.org "Japan - IPv6"\ ftp://ftp2.jp.freebsd.org "Japan #2"\ ftp://ftp3.jp.freebsd.org "Japan #3"\ ftp://ftp4.jp.freebsd.org "Japan #4"\ ftp://ftp6.jp.freebsd.org "Japan #6 - IPv6"\ ftp://ftp.kr.freebsd.org "Korea"\ ftp://ftp2.kr.freebsd.org "Korea #2"\ ftp://ftp.lv.freebsd.org "Latvia"\ ftp://ftp.nl.freebsd.org "Netherlands - IPv6"\ ftp://ftp2.nl.freebsd.org "Netherlands #2"\ ftp://ftp.nz.freebsd.org "New Zealand"\ ftp://ftp.no.freebsd.org "Norway - IPv6"\ ftp://ftp.pl.freebsd.org "Poland - IPv6"\ ftp://ftp.ru.freebsd.org "Russia - IPv6"\ ftp://ftp2.ru.freebsd.org "Russia #2"\ ftp://ftp.si.freebsd.org "Slovenia - IPv6"\ ftp://ftp.za.freebsd.org "South Africa - IPv6"\ ftp://ftp2.za.freebsd.org "South Africa #2 - IPv6"\ ftp://ftp4.za.freebsd.org "South Africa #4"\ ftp://ftp.se.freebsd.org "Sweden - IPv6"\ ftp://ftp4.tw.freebsd.org "Taiwan #4"\ ftp://ftp5.tw.freebsd.org "Taiwan #5"\ ftp://ftp.uk.freebsd.org "UK - IPv6"\ ftp://ftp2.uk.freebsd.org "UK #2 - IPv6"\ ftp://ftp.ua.FreeBSD.org "Ukraine - IPv6"\ ftp://ftp5.us.freebsd.org "USA #5 - IPv6"\ ftp://ftp11.us.freebsd.org "USA #11 - IPv6"\ ftp://ftp14.us.freebsd.org "USA #14"\ - 2>&1 1>&3` + 2>&1 1>&5` MIRROR_BUTTON=$? -exec 3>&- +exec 5>&- _UNAME_R=`uname -r` _UNAME_R=${_UNAME_R%-p*} case ${_UNAME_R} in *-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE) RELDIR="snapshots" ;; *) RELDIR="releases" ;; esac BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}" case $MIRROR_BUTTON in $BSDDIALOG_ERROR | $BSDDIALOG_CANCEL | $BSDDIALOG_ESC) exit 1 ;; $BSDDIALOG_OK) ;; $BSDDIALOG_EXTRA) - exec 3>&1 + exec 5>&1 BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \ --title "Mirror Selection" \ --inputbox "Please enter the URL to an alternate $OSNAME mirror:" \ - 0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&3` + 0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&5` MIRROR_BUTTON=$? - exec 3>&- + exec 5>&- test $MIRROR_BUTTON -eq $BSDDIALOG_OK || exec $0 $@ ;; esac export BSDINSTALL_DISTSITE echo $BSDINSTALL_DISTSITE >&2 diff --git a/usr.sbin/bsdinstall/scripts/netconfig b/usr.sbin/bsdinstall/scripts/netconfig index bdbbd42b3328..99c129ab61f5 100755 --- a/usr.sbin/bsdinstall/scripts/netconfig +++ b/usr.sbin/bsdinstall/scripts/netconfig @@ -1,219 +1,219 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # All rights reserved. # Copyright (c) 2011 The FreeBSD Foundation # All rights reserved. # # Portions of this software were developed by Bjoern Zeeb # under sponsorship from the FreeBSD Foundation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 INTERFACES="" BSDDIALOG_ITEMS="" : ${BSDDIALOG_OK=0} : ${BSDDIALOG_CANCEL=1} : ${BSDDIALOG_HELP=2} : ${BSDDIALOG_EXTRA=3} : ${BSDDIALOG_ESC=5} : ${BSDDIALOG_ERROR=255} for IF in `ifconfig -l`; do test "$IF" = "lo0" && continue (ifconfig -g wlan | egrep -wq $IF) && continue INTERFACES="$INTERFACES $IF" done INTERFACES="$INTERFACES $(sysctl -in net.wlan.devices)" is_wireless_if() { for IF in $(sysctl -in net.wlan.devices); do if [ $IF = $1 ]; then return 0 fi done return 1 } for IF in $INTERFACES; do DESC=`sysctl -n dev.$(echo $IF | sed -E 's/([[:alpha:]]*)([[:digit:]]*)/\1.\2/g').%desc` BSDDIALOG_ITEMS="$BSDDIALOG_ITEMS $IF \"$DESC\"" done if [ -z "$INTERFACES" ]; then bsddialog --backtitle "$OSNAME Installer" \ --title 'Network Configuration Error' \ --msgbox 'No network interfaces present to configure.' 0 0 exit 1 fi -exec 3>&1 -INTERFACE=`echo $BSDDIALOG_ITEMS | xargs -o bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&3` +exec 5>&1 +INTERFACE=`echo $BSDDIALOG_ITEMS | xargs -o bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&5` if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi -exec 3>&- +exec 5>&- : > $BSDINSTALL_TMPETC/._rc.conf.net IFCONFIG_PREFIX="" if is_wireless_if $INTERFACE; then NEXT_WLAN_IFACE=wlan0 # XXX echo wlans_$INTERFACE=\"$NEXT_WLAN_IFACE\" >> $BSDINSTALL_TMPETC/._rc.conf.net IFCONFIG_PREFIX="WPA " if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then ifconfig $NEXT_WLAN_IFACE create wlandev $INTERFACE ifconfig $NEXT_WLAN_IFACE up fi bsdinstall wlanconfig $NEXT_WLAN_IFACE || exec $0 INTERFACE="$NEXT_WLAN_IFACE" fi IPV6_AVAIL=0 IPV4_AVAIL=0 sysctl -N kern.features.inet6 > /dev/null 2>&1 case $? in 0) IPV6_AVAIL=1 ;; esac sysctl -N kern.features.inet > /dev/null 2>&1 case $? in 0) IPV4_AVAIL=1 ;; esac if [ ${IPV4_AVAIL} -eq 1 ]; then bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \ --yesno 'Would you like to configure IPv4 for this interface?' 0 0 if [ $? -eq $BSDDIALOG_OK ]; then bsdinstall netconfig_ipv4 ${INTERFACE} "${IFCONFIG_PREFIX}" || \ exec $0 else IPV4_AVAIL=0 fi fi # In case wlanconfig left an option and we do not support IPv4 we need to write # it out on its own. We cannot write it out with IPv6 as that suffix. if [ ${IPV4_AVAIL} -eq 0 -a -n ${IFCONFIG_PREFIX} ]; then echo ifconfig_${INTERFACE}=\"${IFCONFIG_PREFIX}\" >> $BSDINSTALL_TMPETC/._rc.conf.net fi if [ ${IPV6_AVAIL} -eq 1 ]; then bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \ --yesno 'Would you like to configure IPv6 for this interface?' 0 0 if [ $? -eq $BSDDIALOG_OK ]; then bsdinstall netconfig_ipv6 ${INTERFACE} || exec $0 else IPV6_AVAIL=0 fi fi SEARCH="" IP4_1="" IP4_2="" IP6_1="" IP6_2="" while read key value; do case "${key}" in search) SEARCH="${value}" ;; nameserver) # is more trick as we have to distinguish v4 and v6 case "${value}" in [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) if [ -z "${IP4_1}" ] ; then IP4_1="${value}" elif [ -z "${IP4_2}" ]; then IP4_2="${value}" fi ;; [0-9A-Fa-f:]*:*) if [ -z "${IP6_1}" ] ; then IP6_1="${value}" elif [ -z "${IP6_2}" ]; then IP6_2="${value}" fi ;; esac ;; # ignore others esac done < ${BSDINSTALL_TMPETC}/resolv.conf RESOLV="" if [ ${IPV6_AVAIL} -eq 1 -a ${IPV4_AVAIL} -eq 1 ]; then RESOLV=" 'Search' 1 1 \"${SEARCH}\" 1 16 50 50 0 'Nameserver' 2 1 \"Nameserver\" 2 1 11 11 2 'IPv6 DNS #1' 2 1 \"${IP6_1}\" 2 16 50 50 0 'IPv6 DNS #2' 3 1 \"${IP6_2}\" 3 16 50 50 0 'IPv4 DNS #1' 4 1 \"${IP4_1}\" 4 16 16 16 0 'IPv4 DNS #2' 5 1 \"${IP4_2}\" 5 16 16 16 0" elif [ ${IPV6_AVAIL} -eq 1 ]; then RESOLV=" 'Search' 1 1 \"${SEARCH}\" 1 16 50 50 0 'Nameserver' 2 1 \"Nameserver\" 2 1 11 11 2 'IPv6 DNS #1' 2 1 \"${IP6_1}\" 2 16 50 50 0 'IPv6 DNS #2' 3 1 \"${IP6_2}\" 3 16 50 50 0" elif [ ${IPV4_AVAIL} -eq 1 ]; then RESOLV=" 'Search' 1 1 \"${SEARCH}\" 1 16 50 50 0 'Nameserver' 2 1 \"Nameserver\" 2 1 11 11 2 'IPv4 DNS #1' 2 1 \"${IP4_1}\" 2 16 16 16 0 'IPv4 DNS #2' 3 1 \"${IP4_2}\" 3 16 16 16 0" else exit 0 fi -exec 3>&1 +exec 5>&1 RESOLV=$(echo "${RESOLV}" | xargs -o bsddialog --backtitle "$OSNAME Installer" \ --title 'Network Configuration' \ --mixedform 'Resolver Configuration' 0 0 0 \ -2>&1 1>&3) +2>&1 1>&5) if [ $? -eq $BSDDIALOG_CANCEL ]; then exec $0; fi -exec 3>&- +exec 5>&- echo ${RESOLV} | tr ' ' '\n' | \ awk ' BEGIN { search=-1; } { if (/^[[:space:]]+$/) { next; } if (/^Nameserver$/) { printf "\n"; search=0; next; } if (search == -1) { printf "search "; search=1; } if (search > 0) { printf "%s%s", (search > 1) ? " " : "", $1; search++; next; } printf "nameserver %s\n", $1; }' > ${BSDINSTALL_TMPETC}/resolv.conf mv $BSDINSTALL_TMPETC/._rc.conf.net $BSDINSTALL_TMPETC/rc.conf.net diff --git a/usr.sbin/bsdinstall/scripts/netconfig_ipv4 b/usr.sbin/bsdinstall/scripts/netconfig_ipv4 index 7be4a59194c5..3da1803cd0d1 100755 --- a/usr.sbin/bsdinstall/scripts/netconfig_ipv4 +++ b/usr.sbin/bsdinstall/scripts/netconfig_ipv4 @@ -1,108 +1,108 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # Copyright (c) 2013-2015 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." "$0" f_include $BSDCFG_SHARE/dialog.subr ############################################################ MAIN : ${BSDDIALOG_OK=0} : ${BSDDIALOG_CANCEL=1} INTERFACE=$1 IFCONFIG_PREFIX="$2" test -z "$IFCONFIG_PREFIX" || IFCONFIG_PREFIX="$2 " case "${INTERFACE}" in "") bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \ --msgbox 'No interface specified for IPv4 configuration.' 0 0 exit 1 ;; esac bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0 if [ $? -eq $BSDDIALOG_OK ]; then if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then # XXX: get interface down otherwise after installation restart # dhclient does not build a new resolv.conf (see PR262262). ifconfig $INTERFACE down ifconfig $INTERFACE up bsddialog --backtitle "$OSNAME Installer" --infobox "Acquiring DHCP lease..." 0 0 err=$( pkill -F /var/run/dhclient/dhclient.${INTERFACE}.pid; dhclient $INTERFACE 2>&1 ) if [ $? -ne 0 ]; then f_dprintf "%s" "$err" bsddialog --backtitle "$OSNAME Installer" --msgbox "DHCP lease acquisition failed." 0 0 exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}" fi fi echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/._rc.conf.net exit 0 fi IP_ADDRESS=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $2); }'` NETMASK=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $4); }'` ROUTER=`netstat -rn -f inet | awk '/default/ {printf("%s\n", $2);}'` -exec 3>&1 +exec 5>&1 IF_CONFIG=$(bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' --form 'Static Network Interface Configuration' 0 0 0 \ 'IP Address' 1 1 "$IP_ADDRESS" 1 20 16 0 \ 'Subnet Mask' 2 1 "$NETMASK" 2 20 16 0 \ 'Default Router' 3 1 "$ROUTER" 3 20 16 0 \ -2>&1 1>&3) +2>&1 1>&5) if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi -exec 3>&- +exec 5>&- echo $INTERFACE $IF_CONFIG | awk -v prefix="$IFCONFIG_PREFIX" '{ printf("ifconfig_%s=\"%s\inet %s netmask %s\"\n", $1, prefix, $2, $3); printf("defaultrouter=\"%s\"\n", $4); }' >> $BSDINSTALL_TMPETC/._rc.conf.net retval=$? if [ "$BSDINSTALL_CONFIGCURRENT" ]; then . $BSDINSTALL_TMPETC/._rc.conf.net if [ -n "$2" ]; then ifconfig $INTERFACE `eval echo \\\$ifconfig_$INTERFACE | sed "s|$2||"` else ifconfig $INTERFACE `eval echo \\\$ifconfig_$INTERFACE` fi if [ "$defaultrouter" ]; then route delete -inet default route add -inet default $defaultrouter retval=$? fi fi exit $retval ################################################################################ # END ################################################################################ diff --git a/usr.sbin/bsdinstall/scripts/netconfig_ipv6 b/usr.sbin/bsdinstall/scripts/netconfig_ipv6 index f2d864c539c4..00ef8791de4b 100755 --- a/usr.sbin/bsdinstall/scripts/netconfig_ipv6 +++ b/usr.sbin/bsdinstall/scripts/netconfig_ipv6 @@ -1,162 +1,162 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # Copyright (c) 2011 The FreeBSD Foundation # Copyright (c) 2013-2015 Devin Teske # All rights reserved. # # Portions of this software were developed by Bjoern Zeeb # under sponsorship from the FreeBSD Foundation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." "$0" f_include $BSDCFG_SHARE/dialog.subr ############################################################ MAIN : ${BSDDIALOG_OK=0} : ${BSDDIALOG_CANCEL=1} # # TODO: # - Add DHCPv6 support once FreeBSD ships with it. # INTERFACE=$1 case "${INTERFACE}" in "") bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \ --msgbox 'No interface specified for IPv6 configuration.' 0 0 exit 1 ;; esac AGAIN="" while : ; do MSG="Would you like to try stateless address autoconfiguration (SLAAC)${AGAIN}?" bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \ --yesno "${MSG}" 0 0 if [ $? -eq $BSDDIALOG_OK ]; then if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then bsddialog --backtitle "$OSNAME Installer" \ --infobox "Sending Router Solicitation ..." 0 0 ifconfig ${INTERFACE} inet6 -ifdisabled accept_rtadv up err=$( rtsol -F $INTERFACE 2>&1 ) if [ $? -ne 0 ]; then f_dprintf "%s" "$err" bsddialog --backtitle "$OSNAME Installer" --msgbox "SLAAC failed." 0 0 AGAIN=" again" continue fi fi echo ifconfig_${INTERFACE}_ipv6=\"inet6 accept_rtadv\" >> $BSDINSTALL_TMPETC/._rc.conf.net exit 0 else break fi done ROUTER6=`netstat -Wrn -f inet6 | awk '/default/ {printf("%s\n", $2);}'` ADDRS=`ifconfig ${INTERFACE} inet6 | \ awk -v dfr="${ROUTER6}" ' BEGIN { n=0; } { if (/inet6/) { if (match($2, "^fe80:")) { next; }; # For the moment ignore all but the first address; it might confuse the user. if (n > 0) { next; }; n++; printf "\"IPv6 Address\" %d 1 \"%s/%s\" %d 16 50 50 0 ", n, $2, $4, n; } } END { if (n == 0) { n++; printf "\"IPv6 Address\" %d 1 \"\" %d 16 50 50 0 ", n, n; } n++; # Nasty trick adding a (hidden, same y) read-only field as a marker # to separate interface address(es) from the default router. printf "\"Default Router\" %d 1 \"%s\" %d 1 14 14 2 ", n, "DefaultRouter", n; printf "\"Default Router\" %d 1 \"%s\" %d 16 50 50 0 ", n, dfr, n; }'` -exec 3>&1 +exec 5>&1 IF_CONFIG=$(echo ${ADDRS} | xargs -o bsddialog --backtitle "$OSNAME Installer" \ --title 'Network Configuration' \ --mixedform 'Static IPv6 Network Interface Configuration' 0 0 0 \ -2>&1 1>&3) +2>&1 1>&5) if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi -exec 3>&- +exec 5>&- echo ${IF_CONFIG} | tr ' ' '\n' | \ awk -v iface="${INTERFACE}" ' BEGIN { dfr=0; count=0; } { if (/^[[:space:]]+$/) { next; } if (/DefaultRouter/) { dfr=1; next; } if (dfr == 1) { printf("ipv6_defaultrouter=\"%s\"\n", $1); next; } if (count > 0) { # Ignore all but the first IP address for now. next; } count++; if (!match($1, "/")) { sub("$", "/64", $1); } printf("ifconfig_%s_ipv6=\"inet6 %s\"\n", iface, $1); }' >> $BSDINSTALL_TMPETC/._rc.conf.net retval=$? if [ "$BSDINSTALL_CONFIGCURRENT" ]; then . $BSDINSTALL_TMPETC/._rc.conf.net ifconfig ${INTERFACE} `eval echo \\\$ifconfig_${INTERFACE}_ipv6` if [ "$ipv6_defaultrouter" ]; then route delete -inet6 default route add -inet6 default ${ipv6_defaultrouter} retval=$? fi fi exit $retval ################################################################################ # END ################################################################################ diff --git a/usr.sbin/bsdinstall/scripts/script b/usr.sbin/bsdinstall/scripts/script index 1c617835c274..ae1c6b3011fa 100755 --- a/usr.sbin/bsdinstall/scripts/script +++ b/usr.sbin/bsdinstall/scripts/script @@ -1,182 +1,181 @@ #!/bin/sh #- # Copyright (c) 2013 Nathan Whitehorn # Copyright (c) 2013-2015 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." "$0" f_include $BSDCFG_SHARE/dialog.subr f_include $BSDCFG_SHARE/variable.subr ############################################################ CONFIGURATION # VARIABLES: # PARTITIONS # DISTRIBUTIONS # BSDINSTALL_DISTDIR # # Default name of the ZFS boot-pool # : ${ZFSBOOT_POOL_NAME:=zroot} ############################################################ GLOBALS : ${TMPDIR:="/tmp"} # # Strings that should be moved to an i18n file and loaded with f_include_lang() # msg_installation_error="Installation Error!" ############################################################ FUNCTIONS error() { local file f_getvar "$VAR_DEBUG_FILE#+" file if [ "$file" ]; then f_dialog_title "$msg_installation_error" f_dialog_textbox "$file" # No need to restore title, pining for the fjords fi [ -f "$PATH_FSTAB" ] || exit if [ "$ZFSBOOT_DISKS" ]; then zpool export $ZFSBOOT_POOL_NAME else bsdinstall umount fi exit 1 } ############################################################ MAIN set -e trap error EXIT SCRIPT="$1" shift f_dprintf "Began Installation at %s" "$( date )" rm -rf $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript- . $TMPDIR/bsdinstall-installscript-aa : ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS export BSDINSTALL_DISTDIR # Re-initialize a new log if preamble changed BSDINSTALL_LOG if [ "$BSDINSTALL_LOG" != "${debugFile#+}" ]; then export debugFile="$BSDINSTALL_LOG" f_quietly f_debug_init # NB: Being scripted, let debug go to terminal for invalid debugFile f_dprintf "Began Installation at %s" "$( date )" fi # Make partitions rm -f $PATH_FSTAB touch $PATH_FSTAB if [ "$ZFSBOOT_DISKS" ]; then bsdinstall zfsboot else bsdinstall scriptedpart "$PARTITIONS" fi bsdinstall mount # Fetch missing distribution files, if any -( - exec 3>&1 - export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&3) - FETCH_RESULT=$? - exec 3>&- - return $FETCH_RESULT -) || error "Could not fetch remote distributions" +exec 5>&1 +export BSDINSTALL_DISTDIR=$(`dirname $0`/fetchmissingdists 2>&1 1>&5) +FETCH_RESULT=$? +exec 5>&- + +[ $FETCH_RESULT -ne 0 ] && error "Could not fetch remote distributions" # Unpack distributions bsdinstall checksum if [ -t 0 ]; then # If install is a tty, use distextract as normal bsdinstall distextract else # Otherwise, we need to use tar (see https://reviews.freebsd.org/D10736) for set in $DISTRIBUTIONS; do f_dprintf "Extracting $BSDINSTALL_DISTDIR/$set" # XXX: The below fails if any mountpoints are FAT, due to # inability to set ctime/mtime on the root of FAT partitions, # which is needed to support e.g. EFI system partitions. tar has # no option to ignore this (distextract ignores them internally # through a hack), and returns 1 on any warning or error, # effectively turning all warnings into fatal errors. # # Work around this in an extremely lame way for the specific # case of EFI system partitions only. This *ONLY WORKS* if # /boot/efi is empty and does not handle analagous problems on # other systems (ARM, PPC64). tar -xf "$BSDINSTALL_DISTDIR/$set" -C $BSDINSTALL_CHROOT --exclude boot/efi mkdir -p $BSDINSTALL_CHROOT/boot/efi done fi # Configure bootloader if needed bsdinstall bootconfig # Finalize install bsdinstall config # Make sure networking is functional, if we can arrange that if [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then cp /etc/resolv.conf $BSDINSTALL_CHROOT/etc/resolv.conf fi # Run post-install script if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript chmod a+x $BSDINSTALL_CHROOT/tmp/installscript chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 rm $BSDINSTALL_CHROOT/tmp/installscript fi bsdinstall entropy bsdinstall umount if [ "$ZFSBOOT_DISKS" ]; then zpool export $ZFSBOOT_POOL_NAME fi f_dprintf "Installation Completed at %s" "$( date )" trap - EXIT exit $SUCCESS ################################################################################ # END ################################################################################ diff --git a/usr.sbin/bsdinstall/scripts/services b/usr.sbin/bsdinstall/scripts/services index 025aaa444cd1..93282effbb3f 100755 --- a/usr.sbin/bsdinstall/scripts/services +++ b/usr.sbin/bsdinstall/scripts/services @@ -1,89 +1,89 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 : ${BSDDIALOG_OK=0} if [ -f $BSDINSTALL_TMPETC/rc.conf.services ]; then eval "$( sed -E -e 's/\<(YES|AUTO)\>/on/i' -e 's/\/off/i' \ $BSDINSTALL_TMPETC/rc.conf.services )" else # Default service states. Everything is off if not enabled. sshd_enable="on" fi echo -n > $BSDINSTALL_TMPETC/rc.conf.services -exec 3>&1 +exec 5>&1 DAEMONS=$( bsddialog --backtitle "$OSNAME Installer" \ --title "System Configuration" --no-cancel --separate-output \ --checklist "Choose the services you would like to be started at boot:" \ 0 0 0 \ local_unbound "Local caching validating resolver" \ ${local_unbound_enable:-off} \ sshd "Secure shell daemon" ${sshd_enable:-off} \ moused "PS/2 mouse pointer on console" ${moused_enable:-off} \ ntpd "Synchronize system and network time" ${ntpd_enable:-off} \ ntpd_sync_on_start "Sync time on ntpd startup, even if offset is high" \ ${ntpd_sync_on_start:-off} \ powerd "Adjust CPU frequency dynamically if supported" \ ${powerd_enable:-off} \ dumpdev "Enable kernel crash dumps to /var/crash" ${dumpdev:-on} \ -2>&1 1>&3 ) +2>&1 1>&5 ) retval=$? -exec 3>&- +exec 5>&- if [ $retval -ne $BSDDIALOG_OK ]; then exit 1 fi havedump= havemouse= for daemon in $DAEMONS; do [ "$daemon" = "dumpdev" ] && havedump=1 continue [ "$daemon" = "moused" ] && havemouse=1 if [ "$daemon" = "ntpd_sync_on_start" ]; then rcvar=${daemon} else rcvar=${daemon}_enable fi echo ${rcvar}=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services done if [ ! "$havemouse" ]; then echo moused_nondefault_enable=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services fi echo '# Set dumpdev to "AUTO" to enable crash dumps, "NO"' \ 'to disable' >> $BSDINSTALL_TMPETC/rc.conf.services if [ "$havedump" ]; then echo dumpdev=\"AUTO\" >> $BSDINSTALL_TMPETC/rc.conf.services else echo dumpdev=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services fi diff --git a/usr.sbin/bsdinstall/scripts/time b/usr.sbin/bsdinstall/scripts/time index bba58d291cbd..1d66fa4d5fcf 100755 --- a/usr.sbin/bsdinstall/scripts/time +++ b/usr.sbin/bsdinstall/scripts/time @@ -1,69 +1,69 @@ #!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 # Select timezone chroot $BSDINSTALL_CHROOT tzsetup # Switch to target timezone saved_TZ="$TZ" TZ="${BSDINSTALL_CHROOT}/etc/localtime" export TZ # Set date -exec 3>&1 +exec 5>&1 DATE=$(bsddialog --backtitle "$OSNAME Installer" \ --title 'Time & Date' \ --ok-label 'Set Date' \ --cancel-label 'Skip' \ --default-no \ --date-format '%Y%m%d%H%M.%S' \ --datebox '' 0 40 \ -2>&1 1>&3) && date $DATE -exec 3>&- +2>&1 1>&5) && date $DATE +exec 5>&- # Set time -exec 3>&1 +exec 5>&1 TIME=$(bsddialog --backtitle "$OSNAME Installer" \ --title 'Time & Date' \ --ok-label 'Set Time' \ --cancel-label 'Skip' \ --default-no \ --time-format '%H%M.%S' \ --timebox '' 0 40 \ -2>&1 1>&3) && date $TIME -exec 3>&- +2>&1 1>&5) && date $TIME +exec 5>&- # Switch back if [ -n "$saved_TZ" ]; then TZ="$saved_TZ" else unset TZ fi unset saved_TZ