Skip to content

Commit

Permalink
bsdinstall: allow whitelabeling the scripts
Browse files Browse the repository at this point in the history
Approved by:		allanjude, asiciliano
Differential Revision:	https://reviews.freebsd.org/D35197
Sponsored by:		Rubicon Communications, LLC ("Netgate")
  • Loading branch information
brd committed May 24, 2022
1 parent 33005c8 commit cc42ef5
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 59 deletions.
6 changes: 6 additions & 0 deletions usr.sbin/bsdconfig/share/common.subr
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ if [ ! "$_COMMON_SUBR" ]; then _COMMON_SUBR=1
: ${TERMINAL_STDOUT_PASSTHRU:=3}
: ${TERMINAL_STDERR_PASSTHRU:=4}

#
# Default OSNAME shown in the installer
#
: ${OSNAME:=FreeBSD}
: ${EFI_LABEL_NAME:=FreeBSD}

############################################################ GLOBALS

#
Expand Down
5 changes: 4 additions & 1 deletion usr.sbin/bsdinstall/scripts/adduser
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
#
# $FreeBSD$

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1

clear
echo "FreeBSD Installer"
echo "$OSNAME Installer"
echo "========================"
echo "Add Users"
echo
Expand Down
18 changes: 9 additions & 9 deletions usr.sbin/bsdinstall/scripts/auto
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ 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="FreeBSD Installer"
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"
Expand Down Expand Up @@ -160,7 +160,7 @@ if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
if [ -n "$DISTMENU" ]; then
exec 3>&1
EXTRA_DISTS=$( eval dialog \
--backtitle \"FreeBSD Installer\" \
--backtitle \"$OSNAME Installer\" \
--title \"Distribution Select\" --nocancel --separate-output \
--checklist \"Choose optional system components to install:\" \
0 0 0 $DISTMENU \
Expand All @@ -179,7 +179,7 @@ for dist in $DISTRIBUTIONS; do
done

if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then
dialog --backtitle "FreeBSD 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
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
Expand Down Expand Up @@ -299,7 +299,7 @@ case $CURARCH in
esac

exec 3>&1
PARTMODE=`echo $PMODES | xargs dialog --backtitle "FreeBSD Installer" \
PARTMODE=`echo $PMODES | xargs dialog --backtitle "$OSNAME Installer" \
--title "Partitioning" \
--item-help \
--menu "How would you like to partition your disk?" \
Expand Down Expand Up @@ -358,15 +358,15 @@ bsdinstall time
bsdinstall services
bsdinstall hardening

dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
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
REVISIT=$(dialog --backtitle "FreeBSD Installer" \
REVISIT=$(dialog --backtitle "$OSNAME Installer" \
--title "Final Configuration" --no-cancel --menu \
"Setup of your FreeBSD system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
"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" \
Expand All @@ -375,7 +375,7 @@ finalconfig() {
"Services" "Set daemons to run on startup" \
"System Hardening" "Set security options" \
"Time Zone" "Set system timezone" \
"Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 1>&3)
"Handbook" "Install $OSNAME Handbook (requires network)" 2>&1 1>&3)
exec 3>&-

case "$REVISIT" in
Expand Down Expand Up @@ -424,7 +424,7 @@ if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
rm -rf "$BSDINSTALL_FETCHDEST"
fi

dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \
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
Expand Down
18 changes: 8 additions & 10 deletions usr.sbin/bsdinstall/scripts/bootconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
# $FreeBSD$


FREEBSD_BOOTLABEL="FreeBSD"

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading_includes..." "$0"
Expand Down Expand Up @@ -65,31 +63,31 @@ dialog_uefi_entryname()

update_uefi_bootentry()
{
nentries=$(efibootmgr | grep -c 'FreeBSD$')
nentries=$(efibootmgr | grep -c "${EFI_LABEL_NAME}$")
# No entries so directly create one and return
if [ ${nentries} -eq 0 ]; then
f_dprintf "Creating UEFI boot entry"
efibootmgr --create --activate --label "$FREEBSD_BOOTLABEL" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
return
fi

$DIALOG --backtitle 'FreeBSD Installer' --title 'Boot configuration' \
--yesno 'There are multiple "FreeBSD" EFI boot entries. Would you like to remove them all and add a new one?' 0 0
$DIALOG --backtitle "$OSNAME Installer" --title 'Boot configuration' \
--yesno "There are multiple \"$OSNAME\" EFI boot entries. Would you like to remove them all and add a new one?" 0 0
if [ $? -eq $DIALOG_OK ]; then
for entry in $(efibootmgr | awk '$NF == "FreeBSD" { sub(/.*Boot/,"", $1); sub(/\*/,"", $1); print $1 }'); do
for entry in $(efibootmgr | awk "\$NF == \"$EFI_LABEL_NAME\" { sub(/.*Boot/,\"\", \$1); sub(/\*/,\"\", \$1); print \$1 }"); do
efibootmgr -B -b ${entry}
done
efibootmgr --create --activate --label "$FREEBSD_BOOTLABEL" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
efibootmgr --create --activate --label "$EFI_LABEL_NAME" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
return
fi

FREEBSD_BOOTLABEL=$(dialog_uefi_entryname "${FREEBSD_BOOTLABEL}")
FREEBSD_BOOTLABEL=$(dialog_uefi_entryname "${EFI_LABEL_NAME}")
[ $? -eq $DIALOG_CANCEL ] && exit 1
efibootmgr --create --activate --label "$FREEBSD_BOOTLABEL" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
}

f_dialog_title "Boot configuration"
f_dialog_backtitle "FreeBSD Installer"
f_dialog_backtitle "$OSNAME Installer"

if [ `uname -m` == powerpc ]; then
platform=`sysctl -n hw.platform`
Expand Down
9 changes: 6 additions & 3 deletions usr.sbin/bsdinstall/scripts/checksum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1

percentage=0
for dist in $DISTRIBUTIONS; do
distname=$(basename $dist .txz)
Expand All @@ -37,7 +40,7 @@ for dist in $DISTRIBUTIONS; do
for i in $DISTRIBUTIONS; do
items="$items $i `eval echo \\\${status_$(basename $i .txz):--11}`"
done
bsddialog --backtitle "FreeBSD Installer" --title "Checksum Verification" \
bsddialog --backtitle "$OSNAME Installer" --title "Checksum Verification" \
--mixedgauge "\nVerifying checksums of selected distributions.\n" \
0 0 $percentage -- $items

Expand All @@ -64,11 +67,11 @@ for dist in $DISTRIBUTIONS; do
eval "status_$distname=-2"
case $(/bin/freebsd-version -u) in
*-ALPHA*|*-CURRENT|*-STABLE|*-PRERELEASE)
bsddialog --backtitle "FreeBSD Installer" --title "Error" \
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
--msgbox "The checksum for $dist does not match. It may have become corrupted, or it may be from a newer version of FreeBSD. Please check for a newer snapshot." 0 0
;;
*)
bsddialog --backtitle "FreeBSD Installer" --title "Error" \
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
--msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0
;;
esac
Expand Down
6 changes: 3 additions & 3 deletions usr.sbin/bsdinstall/scripts/docsinstall
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ msg_bndoc_desc="Bengali Documentation"
msg_cancel="Cancel"
msg_dadoc_desc="Danish Documentation"
msg_dedoc_desc="German Documentation"
msg_docsinstall_menu_text="This menu allows you to install the whole documentation set from\nthe FreeBSD Documentation Project: Handbook, FAQ, and articles.\n\nPlease select the language versions you wish to install. At\nminimum, you should install the English version, the original\nversion of the documentation."
msg_docsinstall_menu_text="This menu allows you to install the whole documentation set from\nthe $OSNAME Documentation Project: Handbook, FAQ, and articles.\n\nPlease select the language versions you wish to install. At\nminimum, you should install the English version, the original\nversion of the documentation."
msg_eldoc_desc="Greek Documentation"
msg_endoc_desc="English Documentation (recommended)"
msg_esdoc_desc="Spanish Documentation"
msg_frdoc_desc="French Documentation"
msg_freebsd_documentation_installation="FreeBSD Documentation Installation"
msg_freebsd_installer="FreeBSD Installer"
msg_freebsd_documentation_installation="$OSNAME Documentation Installation"
msg_freebsd_installer="$OSNAME Installer"
msg_hudoc_desc="Hungarian Documentation"
msg_itdoc_desc="Italian Documentation"
msg_jadoc_desc="Japanese Documentation"
Expand Down
2 changes: 1 addition & 1 deletion usr.sbin/bsdinstall/scripts/fetchmissingdists
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ else
VERIFY_MANIFEST_SIG=1

# XXX actually verify signature on manifest
bsddialog --backtitle "FreeBSD 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
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
Expand Down
5 changes: 4 additions & 1 deletion usr.sbin/bsdinstall/scripts/hardening
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
#
# $FreeBSD$

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
FEATURES=$( bsddialog --backtitle "FreeBSD Installer" \
FEATURES=$( bsddialog --backtitle "$OSNAME Installer" \
--title "System Hardening" --nocancel --separate-output \
--checklist "Choose system security hardening options:" \
0 0 0 \
Expand Down
2 changes: 1 addition & 1 deletion usr.sbin/bsdinstall/scripts/hostname
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ f_include $BSDCFG_SHARE/dialog.subr
#
# Strings that should be moved to an i18n file and loaded with f_include_lang()
#
msg_freebsd_installer="FreeBSD Installer"
msg_freebsd_installer="$OSNAME Installer"
msg_ok="OK"
msg_please_choose_a_hostname="Please choose a hostname for this machine.\n\nIf you are running on a managed network, please ask\nyour network administrator for an appropriate name."
msg_set_hostname="Set Hostname"
Expand Down
6 changes: 3 additions & 3 deletions usr.sbin/bsdinstall/scripts/jail
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ error() {
if [ -n "$1" ]; then
msg="$1\n\n"
fi
bsddialog --backtitle "FreeBSD Installer" --title "Abort" \
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
Expand Down Expand Up @@ -84,7 +84,7 @@ if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
then
exec 3>&1
EXTRA_DISTS=$(echo $DISTMENU | xargs -o bsddialog \
--backtitle "FreeBSD Installer" \
--backtitle "$OSNAME Installer" \
--title "Distribution Select" --no-cancel --separate-output \
--checklist "Choose optional system components to install:" \
0 0 0 \
Expand Down Expand Up @@ -130,7 +130,7 @@ if [ ! "$nonInteractive" == "YES" ]
then
bsdinstall services

bsddialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
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
Expand Down
4 changes: 2 additions & 2 deletions usr.sbin/bsdinstall/scripts/keymap
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ hline_arrows_tab_enter="Press arrows, TAB or ENTER"
msg_continue_with_keymap="Continue with %s keymap"
msg_default="default"
msg_error="Error"
msg_freebsd_installer="FreeBSD Installer"
msg_keymap_menu_text="The system console driver for FreeBSD defaults to standard \"US\"\nkeyboard map. Other keymaps can be chosen below."
msg_freebsd_installer="$OSNAME Installer"
msg_keymap_menu_text="The system console driver for $OSNAME defaults to standard \"US\"\nkeyboard map. Other keymaps can be chosen below."
msg_keymap_selection="Keymap Selection"
msg_ok="OK"
msg_select="Select"
Expand Down
9 changes: 6 additions & 3 deletions usr.sbin/bsdinstall/scripts/mirrorselect
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#
# $FreeBSD$

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1

: ${BSDDIALOG_OK=0}
: ${BSDDIALOG_CANCEL=1}
: ${BSDDIALOG_HELP=2}
Expand All @@ -34,7 +37,7 @@
: ${BSDDIALOG_ERROR=255}

exec 3>&1
MIRROR=`bsddialog --backtitle "FreeBSD Installer" \
MIRROR=`bsddialog --backtitle "$OSNAME Installer" \
--title "Mirror Selection" --extra-button --extra-label "Other" \
--menu "Please select the site closest to you or \"other\" if you'd like to specify a different choice. Also note that not every site listed here carries more than the base distribution kits. Only Primary sites are guaranteed to carry the full range of possible distributions. Select a site that's close!" \
0 0 16 \
Expand Down Expand Up @@ -164,9 +167,9 @@ $BSDDIALOG_OK)
;;
$BSDDIALOG_EXTRA)
exec 3>&1
BSDINSTALL_DISTSITE=`bsddialog --backtitle "FreeBSD Installer" \
BSDINSTALL_DISTSITE=`bsddialog --backtitle "$OSNAME Installer" \
--title "Mirror Selection" \
--inputbox "Please enter the URL to an alternate FreeBSD mirror:" \
--inputbox "Please enter the URL to an alternate $OSNAME mirror:" \
0 74 "$BSDINSTALL_DISTSITE" 2>&1 1>&3`
MIRROR_BUTTON=$?
exec 3>&-
Expand Down
5 changes: 4 additions & 1 deletion usr.sbin/bsdinstall/scripts/mount
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#
# $FreeBSD$

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1

TMP_FSTAB=${TMPDIR:-"/tmp"}/bsdinstall-tmp-fstab

cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL_CHROOT '{
Expand All @@ -44,7 +47,7 @@ for i in $FILESYSTEMS; do
mkdir -p $i 2>/dev/null
MNTERROR=`mount -F $TMP_FSTAB $i 2>&1`
if [ $? -ne 0 ]; then
bsddialog --backtitle "FreeBSD Installer" --title "Error" \
bsddialog --backtitle "$OSNAME Installer" --title "Error" \
--msgbox "Error mounting partition $i:\n$MNTERROR" 0 0
exit 1
fi
Expand Down
13 changes: 8 additions & 5 deletions usr.sbin/bsdinstall/scripts/netconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#
# $FreeBSD$

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1

INTERFACES=""
BSDDIALOG_ITEMS=""

Expand Down Expand Up @@ -63,14 +66,14 @@ for IF in $INTERFACES; do
done

if [ -z "$INTERFACES" ]; then
bsddialog --backtitle 'FreeBSD Installer' \
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 'FreeBSD Installer' --title 'Network Configuration' --menu 'Please select a network interface to configure:' 0 0 0 2>&1 1>&3`
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`
if [ $? -eq $BSDDIALOG_CANCEL ]; then exit 1; fi
exec 3>&-

Expand Down Expand Up @@ -101,7 +104,7 @@ case $? in
esac

if [ ${IPV4_AVAIL} -eq 1 ]; then
bsddialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' \
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}" || \
Expand All @@ -116,7 +119,7 @@ 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 'FreeBSD Installer' --title 'Network Configuration' \
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
Expand Down Expand Up @@ -181,7 +184,7 @@ else
fi

exec 3>&1
RESOLV=$(echo "${RESOLV}" | xargs -o bsddialog --backtitle 'FreeBSD Installer' \
RESOLV=$(echo "${RESOLV}" | xargs -o bsddialog --backtitle "$OSNAME Installer" \
--title 'Network Configuration' \
--mixedform 'Resolver Configuration' 0 0 0 \
2>&1 1>&3)
Expand Down
Loading

0 comments on commit cc42ef5

Please sign in to comment.