From a2e9056a00c7050821a0c3b166f67aeded8500f6 Mon Sep 17 00:00:00 2001 From: henrygd Date: Tue, 15 Apr 2025 17:54:53 -0400 Subject: [PATCH] update macos agent install script - adds option to install homebrew if not installed --- supplemental/scripts/install-agent-brew.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/supplemental/scripts/install-agent-brew.sh b/supplemental/scripts/install-agent-brew.sh index 34971de..139b4c7 100755 --- a/supplemental/scripts/install-agent-brew.sh +++ b/supplemental/scripts/install-agent-brew.sh @@ -41,10 +41,23 @@ while getopts "k:p:h" opt; do esac done -# Exit if brew is not installed +# Check if brew is installed, prompt to install if not if ! command -v brew &>/dev/null; then - echo "Homebrew is not installed. Please install Homebrew and try again." - exit 1 + read -p "Homebrew is not installed. Would you like to install it now? (y/n): " install_brew + if [[ $install_brew =~ ^[Yy]$ ]]; then + echo "Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + # Verify installation was successful + if ! command -v brew &>/dev/null; then + echo "Homebrew installation failed. Please install manually and try again." + exit 1 + fi + echo "Homebrew installed successfully." + else + echo "Homebrew is required. Please install Homebrew and try again." + exit 1 + fi fi if [ -z "$KEY" ]; then @@ -67,4 +80,4 @@ echo "Restart: brew services restart beszel-agent" echo "Upgrade: brew upgrade beszel-agent" echo "Uninstall: brew uninstall beszel-agent" echo "View logs in ~/.cache/beszel/beszel-agent.log" -echo "Change environment variables in ~/.config/beszel/beszel-agent.env" +printf "Change environment variables in ~/.config/beszel/beszel-agent.env\n"