Refactored bin script printing

Necessary to have consistent use of `printf` especially with formatting strings and new lines.

Milestone: patch
This commit is contained in:
Brooke Kuhlmann
2024-02-25 08:40:17 -07:00
parent 75d2c93e89
commit 76b193dede
15 changed files with 70 additions and 70 deletions

View File

@@ -2,33 +2,33 @@
# Creates macOS boot disk.
printf "macOS Boot Disk Tips\n"
printf " - Use a USB drive (8GB or higher).\n"
printf " - Use Disk Utility to format the USB drive as \"APSF\".\n"
printf " - Use Disk Utility to label the USB drive as \"Untitled\".\n"
printf "\nmacOS Boot Disk Usage:\n"
printf " 1. Insert the USB boot disk into the machine to be upgraded.\n"
printf " 2. Reboot the machine.\n"
printf " 3. Press and hold the POWER key before the Apple logo appears.\n"
printf " 4. Select the USB boot disk from the menu.\n"
printf " 5. Use Disk Utility to delete and/or erase the hard drive including associated partitions.\n"
printf " 6. Use Disk Utility to create a single \"APFS\" drive.\n"
printf " 7. Install the new operating system.\n"
printf "\nmacOS Boot Disk Recovery:\n"
printf " 1. Start/restart the machine.\n"
printf " 2. Press and hold the POWER key before the Apple logo appears.\n"
printf " 3. Wait for the macOS installer to load from the recovery partition.\n"
printf " 4. Use the dialog options to launch Disk Utility, reinstall the system, etc.\n"
printf "%s\n" "macOS Boot Disk Tips"
printf "%s\n" " - Use a USB drive (8GB or higher)."
printf "%s\n" " - Use Disk Utility to format the USB drive as \"APSF\"."
printf "%s\n" " - Use Disk Utility to label the USB drive as \"Untitled\"."
printf "\n%s\n" "macOS Boot Disk Usage:"
printf "%s\n" " 1. Insert the USB boot disk into the machine to be upgraded."
printf "%s\n" " 2. Reboot the machine."
printf "%s\n" " 3. Press and hold the POWER key before the Apple logssssso appears."
printf "%s\n" " 4. Select the USB boot disk from the menu."
printf "%s\n" " 5. Use Disk Utility to delete and/or erase the hard drive including associated partitions."
printf "%s\n" " 6. Use Disk Utility to create a single \"APFS\" drive."
printf "%s\n" " 7. Install the new operating system."
printf "\n%s\n" "macOS Boot Disk Recovery:"
printf "%s\n" " 1. Start/restart the machine."
printf "%s\n" " 2. Press and hold the POWER key before the Apple logo appears."
printf "%s\n" " 3. Wait for the macOS installer to load from the recovery partition."
printf "%s\n" " 4. Use the dialog options to launch Disk Utility, reinstall the system, etc."
printf "\nCreating macOS boot disk...\n"
printf "\n%s\n" "Creating macOS boot disk..."
if [[ ! -e "$MAC_OS_BOOT_DISK_CREATOR" ]]; then
printf "ERROR: macOS installer does not exist: $MAC_OS_BOOT_DISK_CREATOR. Use System Preferences → Software Update to download.\n"
printf "%s\n" "ERROR: macOS installer does not exist: $MAC_OS_BOOT_DISK_CREATOR. Use System Preferences → Software Update to download."
exit 1
fi
if [[ ! -d "$MAC_OS_BOOT_DISK_PATH" ]]; then
printf "ERROR: Boot disk must be mounted at: $MAC_OS_BOOT_DISK_PATH.\n"
printf "%s\n" "ERROR: Boot disk must be mounted at: $MAC_OS_BOOT_DISK_PATH."
exit 1
fi

View File

@@ -13,5 +13,5 @@ if [[ -x "$SCRIPT_PATH" ]]; then
check_mas_install
"$SCRIPT_PATH"
else
printf "WARNING: App Store install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: App Store install script does not exist or is not executable."
fi

View File

@@ -12,5 +12,5 @@ SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_applications"
if [[ -x "$SCRIPT_PATH" ]]; then
"$SCRIPT_PATH"
else
printf "WARNING: Applications install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Applications install script does not exist or is not executable."
fi

View File

@@ -12,5 +12,5 @@ SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_basics"
if [[ -x "$SCRIPT_PATH" ]]; then
"$SCRIPT_PATH"
else
printf "WARNING: Basic settings script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Basic settings script does not exist or is not executable."
fi

View File

@@ -12,5 +12,5 @@ SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_defaults"
if [[ -x "$SCRIPT_PATH" ]]; then
"$SCRIPT_PATH"
else
printf "WARNING: Default settings script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Default settings script does not exist or is not executable."
fi

View File

@@ -1,14 +1,14 @@
#! /usr/bin/env bash
Installs development tooling requirements.
# Installs development tooling requirements.
printf "Installing Xcode CLI tools...\n"
printf "%s\n" "Installing Xcode CLI tools..."
xcode-select --install
printf "%s\n" "💡 ALT+TAB to view and accept Xcode license window."
read -p "Have you completed the Xcode CLI tools install (y/n)? " xcode_response
if [[ "$xcode_response" != "y" ]]; then
printf "ERROR: Xcode CLI tools must be installed before proceeding.\n"
printf "%s\n" "ERROR: Xcode CLI tools must be installed before proceeding."
exit 1
fi

View File

@@ -12,5 +12,5 @@ SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_extensions"
if [[ -x "$SCRIPT_PATH" ]]; then
"$SCRIPT_PATH"
else
printf "WARNING: Application extensions install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Application extensions install script does not exist or is not executable."
fi

View File

@@ -13,5 +13,5 @@ if [[ -x "$SCRIPT_PATH" ]]; then
install_homebrew
"$SCRIPT_PATH"
else
printf "WARNING: Homebrew Casks install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Homebrew Casks install script does not exist or is not executable."
fi

View File

@@ -13,5 +13,5 @@ if [[ -x "$SCRIPT_PATH" ]]; then
install_homebrew
"$SCRIPT_PATH"
else
printf "WARNING: Homebrew Formulas install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Homebrew Formulas install script does not exist or is not executable."
fi

View File

@@ -13,5 +13,5 @@ if [[ -x "$SCRIPT_PATH" ]]; then
install_node
"$SCRIPT_PATH"
else
printf "WARNING: Node packages install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Node packages install script does not exist or is not executable."
fi

View File

@@ -13,5 +13,5 @@ if [[ -x "$SCRIPT_PATH" ]]; then
install_ruby
"$SCRIPT_PATH"
else
printf "WARNING: Ruby gems install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Ruby gems install script does not exist or is not executable."
fi

View File

@@ -13,5 +13,5 @@ if [[ -x "$SCRIPT_PATH" ]]; then
install_rust
"$SCRIPT_PATH"
else
printf "WARNING: Rust crates install script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Rust crates install script does not exist or is not executable."
fi

View File

@@ -12,5 +12,5 @@ SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_shell"
if [[ -x "$SCRIPT_PATH" ]]; then
"$SCRIPT_PATH"
else
printf "WARNING: Shell script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Shell script does not exist or is not executable."
fi

View File

@@ -12,5 +12,5 @@ SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/restore_backup"
if [[ -x "$SCRIPT_PATH" ]]; then
"$SCRIPT_PATH"
else
printf "WARNING: Restore backup script does not exist or is not executable.\n"
printf "%s\n" "WARNING: Restore backup script does not exist or is not executable."
fi

70
bin/run
View File

@@ -11,13 +11,13 @@ source lib/verifiers.sh
if [[ -e "$MAC_OS_CONFIG_PATH" ]]; then
source "$MAC_OS_CONFIG_PATH/lib/settings.sh"
else
printf "ERROR: Unable to load macOS configuration: $MAC_OS_CONFIG_PATH.\n\n"
printf "Please check the following before continuing:\n"
printf " • Download the default macOS configuration here: https://github.com/bkuhlmann/mac_os-config.\n"
printf " • Customize as necessary for your setup or fork the project and make your own configuration.\n"
printf " • When finished, your folder structure should look like this:\n"
printf " • <root path>/mac_os:\n"
printf " • <root path>/mac_os-config:\n"
printf "%s\n\n" "ERROR: Unable to load macOS configuration: $MAC_OS_CONFIG_PATH."
printf "%s\n" "Please check the following before continuing:"
printf "%s\n" " • Download the default macOS configuration here: https://github.com/bkuhlmann/mac_os-config."
printf "%s\n" " • Customize as necessary for your setup or fork the project and make your own configuration."
printf "%s\n" " • When finished, your folder structure should look like this:"
printf "%s\n" " • <root path>/mac_os:"
printf "%s\n" " • <root path>/mac_os-config:"
exit 1
fi
@@ -25,37 +25,37 @@ configure_environment
while true; do
if [[ $# == 0 ]]; then
printf "\nUsage: run OPTION\n"
printf "\nOSX Options:\n"
printf " Boot:\n"
printf " B: Create boot disk.\n"
printf " Install:\n"
printf " b: Install basics.\n"
printf " t: Install development tools.\n"
printf " hf: Install Homebrew Formulas.\n"
printf " hc: Install Homebrew Casks.\n"
printf " m: Install Mac App Store software.\n"
printf " a: Install application software.\n"
printf " x: Install application software extensions.\n"
printf " d: Install defaults.\n"
printf " s: Install shell.\n"
printf " r: Restore backups.\n"
printf " i: Install all (i.e. executes all of the above steps in order listed).\n"
printf " Libraries:\n"
printf " np: Install Node packages.\n"
printf " rg: Install Ruby gems.\n"
printf " rc: Install Rust crates.\n"
printf " l: Install libraries (i.e. executes all of the above steps in order listed).\n"
printf " Manage:\n"
printf " c: Check status of managed software.\n"
printf " C: Caffeinate machine.\n"
printf " w: Clean work (temp) directory.\n"
printf " q: Quit/Exit.\n\n"
printf "\n%s\n" "Usage: run OPTION"
printf "\n%s\n" "OSX Options:"
printf "%s\n" " Boot:"
printf "%s\n" " B: Create boot disk."
printf "%s\n" " Install:"
printf "%s\n" " b: Install basics."
printf "%s\n" " t: Install development tools."
printf "%s\n" " hf: Install Homebrew Formulas."
printf "%s\n" " hc: Install Homebrew Casks."
printf "%s\n" " m: Install Mac App Store software."
printf "%s\n" " a: Install application software."
printf "%s\n" " x: Install application software extensions."
printf "%s\n" " d: Install defaults."
printf "%s\n" " s: Install shell."
printf "%s\n" " r: Restore backups."
printf "%s\n" " i: Install all (i.e. executes all of the above steps in order listed)."
printf "%s\n" " Libraries:"
printf "%s\n" " np: Install Node packages."
printf "%s\n" " rg: Install Ruby gems."
printf "%s\n" " rc: Install Rust crates."
printf "%s\n" " l: Install libraries (i.e. executes all of the above steps in order listed)."
printf "%s\n" " Manage:"
printf "%s\n" " c: Check status of managed software."
printf "%s\n" " C: Caffeinate machine."
printf "%s\n" " w: Clean work (temp) directory."
printf "%s\n\n" " q: Quit/Exit."
read -p "Enter selection: " response
printf "\n"
process_option $response
process_option "$response"
else
process_option $1
process_option "$1"
fi
break