From dda72198ff8ec564a3b5bbbc1702c6db80d8ac1b Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Mon, 13 Nov 2023 06:32:18 +0000 Subject: [PATCH] Latest --- .../run_before_01-system-homebrew.sh.tmpl | 8 +++++- scripts/cloudflared-ssh.sh | 20 +++++++++---- scripts/homebrew.sh | 5 ++++ scripts/partials/basic-deps | 15 ++++++---- scripts/partials/homebrew | 5 ++++ scripts/provision.sh | 28 ++++++++++++++----- scripts/src/provision.sh.tmpl | 6 +++- 7 files changed, 68 insertions(+), 19 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl b/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl index ab5a1ae4..0d7bf564 100644 --- a/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_before_01-system-homebrew.sh.tmpl @@ -53,6 +53,7 @@ fi ### System upgrade on macOS if [ -d /Applications ] && [ -d /Library ] && [ -z "$NO_RESTART" ]; then + echo 'bash <(curl -sSL https://install.doctor/start) # TEMPORARY FOR INSTALL DOCTOR MACOS' >> "$HOME/.zshrc" if command -v gtimeout > /dev/null; then # Allow 8 minutes for system updates logg info 'Ensuring system software is upgraded (timing out after 50 minutes if system upgrade fails)' @@ -60,9 +61,14 @@ if [ -d /Applications ] && [ -d /Library ] && [ -z "$NO_RESTART" ]; then else # If gtimeout is unavailable, then attempt system upgrade without a timeout (which usually works on fresh systems) logg info 'Applying OS upgrades (if available)' - sudo softwareupdate -i -a -R || logg error 'Failed to perform a system update via sudo softwareupdate -i -a' + sudo softwareupdate -i -a -R || logg error 'Failed to perform a system update via sudo softwareupdate -i -a -R' fi logg info 'If system updates were downloaded / installed, a reboot might be required.' + if command -v gsed > /dev/null; then + sudo gsed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + else + sudo sed -i '/# TEMPORARY FOR INSTALL DOCTOR MACOS/d' "$HOME/.zshrc" || logg warn "Failed to remove kickstart script from .zshrc" + fi fi ### Ensure dependencies are installed on Linux diff --git a/scripts/cloudflared-ssh.sh b/scripts/cloudflared-ssh.sh index 79fdf052..05ec69f2 100644 --- a/scripts/cloudflared-ssh.sh +++ b/scripts/cloudflared-ssh.sh @@ -106,27 +106,32 @@ logg() { fi } # @description Ensure dependencies like `git` and `curl` are installed (among a few other lightweight system packages) + + if ! command -v curl > /dev/null || ! command -v git > /dev/null || ! command -v expect > /dev/null || ! command -v rsync > /dev/null || ! command -v unbuffer; then if command -v apt-get > /dev/null; then ### Debian / Ubuntu logg info 'Running sudo apt-get update' && sudo apt-get update - logg info 'Running sudo apt-get install -y build-essential curl expect git rsync' && sudo apt-get install -y build-essential curl expect git rsync + logg info 'Running sudo apt-get install -y build-essential curl expect git rsync procps file' && sudo apt-get install -y build-essential curl expect git rsync procps file elif command -v dnf > /dev/null; then ### Fedora - logg info 'Running sudo dnf install -y curl expect git rsync' && sudo dnf install -y curl expect git rsync + logg info 'Running sudo dnf groupinstall -y \'Development Tools\'' && sudo dnf groupinstall -y 'Development Tools' + logg info 'Running sudo dnf install -y curl expect git rsync procps-ng file' && sudo dnf install -y curl expect git rsync procps-ng file elif command -v yum > /dev/null; then ### CentOS - logg info 'Running sudo yum install -y curl expect git rsync' && sudo yum install -y curl expect git rsync + logg info 'Running sudo yum groupinstall -y \'Development Tools\'' && sudo yum groupinstall -y 'Development Tools' + logg info 'Running sudo yum install -y curl expect git rsync procps-ng file' && sudo yum install -y curl expect git rsync procps-ng file elif command -v pacman > /dev/null; then ### Archlinux logg info 'Running sudo pacman update' && sudo pacman update logg info 'Running sudo pacman -Syu base-devel curl expect git rsync procps-ng file' && sudo pacman -Syu base-devel curl expect git rsync procps-ng file elif command -v zypper > /dev/null; then ### OpenSUSE - logg info 'Running sudo zypper install -y curl expect git rsync' && sudo zypper install -y curl expect git rsync + logg info 'Running sudo zypper install -yt pattern devel_basis' && sudo zypper install -yt pattern devel_basis + logg info 'Running sudo zypper install -y curl expect git rsync procps file' && sudo zypper install -y curl expect git rsync procps file elif command -v apk > /dev/null; then ### Alpine - logg info 'Running apk add curl expect git rsync' && apk add curl expect git rsync + logg info 'Running apk add build-base curl expect git rsync procps file' && apk add build-base curl expect git rsync procps file elif [ -d /Applications ] && [ -d /Library ]; then ### macOS logg info "Ensuring Xcode Command Line Tools are installed.." @@ -161,6 +166,11 @@ if ! command -v brew > /dev/null; then if ! command -v brew > /dev/null; then logg error "The /home/linuxbrew/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 fi + elif [ -d "$HOME/.linuxbrew" ]; then + logg info "Sourcing from $HOME/.linuxbrew/bin/brew" && eval "$($HOME/.linuxbrew/bin/brew shellenv)" + if ! command -v brew > /dev/null; then + logg error "The $HOME/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 + fi else ### Installs Homebrew and addresses a couple potential issues if command -v sudo > /dev/null && sudo -n true; then diff --git a/scripts/homebrew.sh b/scripts/homebrew.sh index c4fe0fe3..b020e46e 100644 --- a/scripts/homebrew.sh +++ b/scripts/homebrew.sh @@ -17,6 +17,11 @@ if ! command -v brew > /dev/null; then if ! command -v brew > /dev/null; then logg error "The /home/linuxbrew/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 fi + elif [ -d "$HOME/.linuxbrew" ]; then + logg info "Sourcing from $HOME/.linuxbrew/bin/brew" && eval "$($HOME/.linuxbrew/bin/brew shellenv)" + if ! command -v brew > /dev/null; then + logg error "The $HOME/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 + fi else ### Installs Homebrew and addresses a couple potential issues if command -v sudo > /dev/null && sudo -n true; then diff --git a/scripts/partials/basic-deps b/scripts/partials/basic-deps index b63a993a..e2e0310e 100644 --- a/scripts/partials/basic-deps +++ b/scripts/partials/basic-deps @@ -1,24 +1,29 @@ + + if ! command -v curl > /dev/null || ! command -v git > /dev/null || ! command -v expect > /dev/null || ! command -v rsync > /dev/null || ! command -v unbuffer; then if command -v apt-get > /dev/null; then ### Debian / Ubuntu logg info 'Running sudo apt-get update' && sudo apt-get update - logg info 'Running sudo apt-get install -y build-essential curl expect git rsync' && sudo apt-get install -y build-essential curl expect git rsync + logg info 'Running sudo apt-get install -y build-essential curl expect git rsync procps file' && sudo apt-get install -y build-essential curl expect git rsync procps file elif command -v dnf > /dev/null; then ### Fedora - logg info 'Running sudo dnf install -y curl expect git rsync' && sudo dnf install -y curl expect git rsync + logg info 'Running sudo dnf groupinstall -y \'Development Tools\'' && sudo dnf groupinstall -y 'Development Tools' + logg info 'Running sudo dnf install -y curl expect git rsync procps-ng file' && sudo dnf install -y curl expect git rsync procps-ng file elif command -v yum > /dev/null; then ### CentOS - logg info 'Running sudo yum install -y curl expect git rsync' && sudo yum install -y curl expect git rsync + logg info 'Running sudo yum groupinstall -y \'Development Tools\'' && sudo yum groupinstall -y 'Development Tools' + logg info 'Running sudo yum install -y curl expect git rsync procps-ng file' && sudo yum install -y curl expect git rsync procps-ng file elif command -v pacman > /dev/null; then ### Archlinux logg info 'Running sudo pacman update' && sudo pacman update logg info 'Running sudo pacman -Syu base-devel curl expect git rsync procps-ng file' && sudo pacman -Syu base-devel curl expect git rsync procps-ng file elif command -v zypper > /dev/null; then ### OpenSUSE - logg info 'Running sudo zypper install -y curl expect git rsync' && sudo zypper install -y curl expect git rsync + logg info 'Running sudo zypper install -yt pattern devel_basis' && sudo zypper install -yt pattern devel_basis + logg info 'Running sudo zypper install -y curl expect git rsync procps file' && sudo zypper install -y curl expect git rsync procps file elif command -v apk > /dev/null; then ### Alpine - logg info 'Running apk add curl expect git rsync' && apk add curl expect git rsync + logg info 'Running apk add build-base curl expect git rsync procps file' && apk add build-base curl expect git rsync procps file elif [ -d /Applications ] && [ -d /Library ]; then ### macOS logg info "Ensuring Xcode Command Line Tools are installed.." diff --git a/scripts/partials/homebrew b/scripts/partials/homebrew index 5075ff9a..2ad17fd0 100644 --- a/scripts/partials/homebrew +++ b/scripts/partials/homebrew @@ -4,6 +4,11 @@ if ! command -v brew > /dev/null; then if ! command -v brew > /dev/null; then logg error "The /home/linuxbrew/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 fi + elif [ -d "$HOME/.linuxbrew" ]; then + logg info "Sourcing from $HOME/.linuxbrew/bin/brew" && eval "$($HOME/.linuxbrew/bin/brew shellenv)" + if ! command -v brew > /dev/null; then + logg error "The $HOME/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 + fi else ### Installs Homebrew and addresses a couple potential issues if command -v sudo > /dev/null && sudo -n true; then diff --git a/scripts/provision.sh b/scripts/provision.sh index 0bd918c9..a6326dc4 100644 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -119,6 +119,7 @@ logg() { # otherwise use the master Install Doctor branch setEnvironmentVariables() { export DEBIAN_FRONTEND=noninteractive + export HOMEBREW_NO_ENV_HINTS=true if [ -z "$START_REPO" ] && [ -z "$REPO" ]; then export START_REPO="https://github.com/megabyte-labs/install.doctor.git" else @@ -140,27 +141,32 @@ setEnvironmentVariables() { # @description Ensure dependencies like `git` and `curl` are installed (among a few other lightweight system packages) ensureBasicDeps() { - if ! command -v curl > /dev/null || ! command -v git > /dev/null || ! command -v expect > /dev/null || ! command -v rsync > /dev/null || ! command -v unbuffer; then + + +if ! command -v curl > /dev/null || ! command -v git > /dev/null || ! command -v expect > /dev/null || ! command -v rsync > /dev/null || ! command -v unbuffer; then if command -v apt-get > /dev/null; then ### Debian / Ubuntu logg info 'Running sudo apt-get update' && sudo apt-get update - logg info 'Running sudo apt-get install -y build-essential curl expect git rsync' && sudo apt-get install -y build-essential curl expect git rsync + logg info 'Running sudo apt-get install -y build-essential curl expect git rsync procps file' && sudo apt-get install -y build-essential curl expect git rsync procps file elif command -v dnf > /dev/null; then ### Fedora - logg info 'Running sudo dnf install -y curl expect git rsync' && sudo dnf install -y curl expect git rsync + logg info 'Running sudo dnf groupinstall -y \'Development Tools\'' && sudo dnf groupinstall -y 'Development Tools' + logg info 'Running sudo dnf install -y curl expect git rsync procps-ng file' && sudo dnf install -y curl expect git rsync procps-ng file elif command -v yum > /dev/null; then ### CentOS - logg info 'Running sudo yum install -y curl expect git rsync' && sudo yum install -y curl expect git rsync + logg info 'Running sudo yum groupinstall -y \'Development Tools\'' && sudo yum groupinstall -y 'Development Tools' + logg info 'Running sudo yum install -y curl expect git rsync procps-ng file' && sudo yum install -y curl expect git rsync procps-ng file elif command -v pacman > /dev/null; then ### Archlinux logg info 'Running sudo pacman update' && sudo pacman update logg info 'Running sudo pacman -Syu base-devel curl expect git rsync procps-ng file' && sudo pacman -Syu base-devel curl expect git rsync procps-ng file elif command -v zypper > /dev/null; then ### OpenSUSE - logg info 'Running sudo zypper install -y curl expect git rsync' && sudo zypper install -y curl expect git rsync + logg info 'Running sudo zypper install -yt pattern devel_basis' && sudo zypper install -yt pattern devel_basis + logg info 'Running sudo zypper install -y curl expect git rsync procps file' && sudo zypper install -y curl expect git rsync procps file elif command -v apk > /dev/null; then ### Alpine - logg info 'Running apk add curl expect git rsync' && apk add curl expect git rsync + logg info 'Running apk add build-base curl expect git rsync procps file' && apk add build-base curl expect git rsync procps file elif [ -d /Applications ] && [ -d /Library ]; then ### macOS logg info "Ensuring Xcode Command Line Tools are installed.." @@ -198,6 +204,11 @@ ensureHomebrew() { if ! command -v brew > /dev/null; then logg error "The /home/linuxbrew/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 fi + elif [ -d "$HOME/.linuxbrew" ]; then + logg info "Sourcing from $HOME/.linuxbrew/bin/brew" && eval "$($HOME/.linuxbrew/bin/brew shellenv)" + if ! command -v brew > /dev/null; then + logg error "The $HOME/.linuxbrew directory exists but something is not right. Try removing it and running the script again." && exit 1 + fi else ### Installs Homebrew and addresses a couple potential issues if command -v sudo > /dev/null && sudo -n true; then @@ -398,7 +409,7 @@ installBrewPackage() { # # 1. Ensures Chezmoi, Node.js, and ZX are installed. # 2. Installs Glow and Gum if the `HEADLESS_INSTALL` environment variable is not set. -# 3. If the system is macOS, then also install `gsed`. +# 3. If the system is macOS, then also install `gsed` and `coreutils`. ensureHomebrewDeps() { ### TUI experience if [ -z "$HEADLESS_INSTALL" ]; then @@ -414,6 +425,9 @@ ensureHomebrewDeps() { ### macOS if [ -d /Applications ] && [ -d /System ]; then installBrewPackage "gsed" + if ! command -v gtimeout > /dev/null; then + brew install coreutils + fi fi } diff --git a/scripts/src/provision.sh.tmpl b/scripts/src/provision.sh.tmpl index 61f9adb1..90713519 100644 --- a/scripts/src/provision.sh.tmpl +++ b/scripts/src/provision.sh.tmpl @@ -58,6 +58,7 @@ # otherwise use the master Install Doctor branch setEnvironmentVariables() { export DEBIAN_FRONTEND=noninteractive + export HOMEBREW_NO_ENV_HINTS=true if [ -z "$START_REPO" ] && [ -z "$REPO" ]; then export START_REPO="https://github.com/megabyte-labs/install.doctor.git" else @@ -246,7 +247,7 @@ installBrewPackage() { # # 1. Ensures Chezmoi, Node.js, and ZX are installed. # 2. Installs Glow and Gum if the `HEADLESS_INSTALL` environment variable is not set. -# 3. If the system is macOS, then also install `gsed`. +# 3. If the system is macOS, then also install `gsed` and `coreutils`. ensureHomebrewDeps() { ### TUI experience if [ -z "$HEADLESS_INSTALL" ]; then @@ -262,6 +263,9 @@ ensureHomebrewDeps() { ### macOS if [ -d /Applications ] && [ -d /System ]; then installBrewPackage "gsed" + if ! command -v gtimeout > /dev/null; then + brew install coreutils + fi fi }