Created
February 13, 2026 10:32
-
-
Save jalogisch/e96537c89cdfcca62a2e9229ac3e0ce5 to your computer and use it in GitHub Desktop.
Support team Mac bootstrap script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #============================================================================== | |
| # Support Team Tooling Bootstrap Script | |
| #============================================================================== | |
| # One-liner bootstrap for setting up the Support Team tooling environment. | |
| # | |
| # Usage (from a fresh Mac): | |
| # /bin/bash -c "$(curl -fsSL --max-time 60 https://raw.githubusercontent.com/elastic/support/main/bootstrap-mac.sh)" | |
| # | |
| # Or with custom GITDIR: | |
| # GITDIR=~/code /bin/bash -c "$(curl -fsSL --max-time 60 https://raw.githubusercontent.com/elastic/support/main/bootstrap-mac.sh)" | |
| # | |
| # Options: -d|--debug Enable debug logging; -h|--help Show usage | |
| # | |
| # This script will: | |
| # 1. Install Xcode Command Line Tools (if needed) | |
| # 2. Install Homebrew (if needed) | |
| # 3. Install GitHub CLI (gh) | |
| # 4. Authenticate with GitHub (interactive) | |
| # 5. Clone the elastic/support repository | |
| # 6. Install Oh My Zsh (if needed, for power-ups) | |
| # 7. Run the install-power-ups.sh script | |
| #============================================================================== | |
| set -euo pipefail | |
| DEBUG=${DEBUG:-false} | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| CYAN='\033[0;36m' | |
| BOLD='\033[1m' | |
| NC='\033[0m' # No Color | |
| # Default directories | |
| GITDIR="${GITDIR:-$HOME/bench}" | |
| SUPPORTDIR="${SUPPORTDIR:-$GITDIR/support}" | |
| #============================================================================== | |
| # Helper Functions | |
| #============================================================================== | |
| log_info() { | |
| echo -e "${BLUE}ℹ${NC} $1" | |
| } | |
| log_success() { | |
| echo -e "${GREEN}✓${NC} $1" | |
| } | |
| log_warning() { | |
| echo -e "${YELLOW}⚠${NC} $1" | |
| } | |
| log_error() { | |
| echo -e "${RED}✗${NC} $1" >&2 | |
| } | |
| log_step() { | |
| echo "" | |
| echo -e "${CYAN}${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo -e "${CYAN}${BOLD} $1${NC}" | |
| echo -e "${CYAN}${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "" | |
| } | |
| log_debug() { | |
| [[ "$DEBUG" == "true" ]] && echo -e "[DEBUG] $1" >&2 || true | |
| } | |
| command_exists() { | |
| command -v "$1" >/dev/null 2>&1 | |
| } | |
| # Check if running on macOS | |
| check_macos() { | |
| if [[ "$(uname)" != "Darwin" ]]; then | |
| log_error "This bootstrap script is designed for macOS." | |
| log_info "For Linux, please follow the manual installation instructions in the README." | |
| exit 1 | |
| fi | |
| } | |
| # Ensure we have a tty for interactive prompts | |
| # When piped via curl, stdin is the script itself, so we need to use /dev/tty | |
| ensure_tty() { | |
| if [[ ! -t 0 ]]; then | |
| # stdin is not a terminal (script is being piped) | |
| exec < /dev/tty | |
| fi | |
| } | |
| usage() { | |
| cat <<EOF | |
| Usage: $(basename "$0") [OPTIONS] | |
| Bootstrap Support Team tooling on macOS. | |
| Options: | |
| -d, --debug Enable debug logging | |
| -h, --help Show this help message | |
| Environment: | |
| GITDIR Directory for git repos (default: \$HOME/bench) | |
| SUPPORTDIR Path to support repo (default: \$GITDIR/support) | |
| One-liner (from a fresh Mac): | |
| /bin/bash -c "\$(curl -fsSL --max-time 60 https://raw.githubusercontent.com/elastic/support/main/bootstrap-mac.sh)" | |
| EOF | |
| } | |
| parse_args() { | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| -d|--debug) DEBUG=true; shift ;; | |
| -h|--help) usage; exit 0 ;; | |
| *) | |
| log_error "Unknown option: $1" | |
| usage | |
| exit 2 | |
| ;; | |
| esac | |
| done | |
| } | |
| #============================================================================== | |
| # Step 1: Xcode Command Line Tools | |
| #============================================================================== | |
| install_xcode_cli() { | |
| log_step "Step 1: Xcode Command Line Tools" | |
| # Check if xcode-select is already installed | |
| if xcode-select -p &>/dev/null; then | |
| log_success "Xcode Command Line Tools already installed" | |
| return 0 | |
| fi | |
| log_info "Installing Xcode Command Line Tools..." | |
| log_info "This may take several minutes and require your password." | |
| echo "" | |
| # Trigger the installation prompt | |
| xcode-select --install 2>/dev/null || true | |
| # Wait for installation to complete | |
| log_warning "Please complete the installation dialog that appeared." | |
| log_info "Press Enter once the installation is complete..." | |
| read -r | |
| # Verify installation | |
| if xcode-select -p &>/dev/null; then | |
| log_success "Xcode Command Line Tools installed successfully" | |
| else | |
| log_error "Xcode Command Line Tools installation may have failed." | |
| log_info "Please run: xcode-select --install" | |
| exit 1 | |
| fi | |
| } | |
| #============================================================================== | |
| # Step 2: Homebrew Installation | |
| #============================================================================== | |
| install_homebrew() { | |
| log_step "Step 2: Homebrew Package Manager" | |
| if command_exists brew; then | |
| log_success "Homebrew already installed" | |
| # Ensure brew is in PATH for Apple Silicon Macs | |
| if [[ -f /opt/homebrew/bin/brew ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| fi | |
| return 0 | |
| fi | |
| log_info "Installing Homebrew..." | |
| log_info "This may require your password." | |
| echo "" | |
| # Install Homebrew (this script handles its own prompts) | |
| # Timeout 120s: install script download can be slow on first run | |
| /bin/bash -c "$(curl -fsSL --max-time 120 https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| # Add Homebrew to PATH for the current session | |
| # Apple Silicon Macs use /opt/homebrew, Intel Macs use /usr/local | |
| if [[ -f /opt/homebrew/bin/brew ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| log_info "Homebrew installed to /opt/homebrew (Apple Silicon)" | |
| elif [[ -f /usr/local/bin/brew ]]; then | |
| eval "$(/usr/local/bin/brew shellenv)" | |
| log_info "Homebrew installed to /usr/local (Intel)" | |
| fi | |
| # Verify installation | |
| if command_exists brew; then | |
| log_success "Homebrew installed successfully" | |
| else | |
| log_error "Homebrew installation failed." | |
| log_info "Please visit https://brew.sh for manual installation instructions." | |
| exit 1 | |
| fi | |
| } | |
| #============================================================================== | |
| # Step 3: GitHub CLI Installation | |
| #============================================================================== | |
| install_github_cli() { | |
| log_step "Step 3: GitHub CLI (gh)" | |
| if command_exists gh; then | |
| log_success "GitHub CLI already installed" | |
| return 0 | |
| fi | |
| log_info "Installing GitHub CLI via Homebrew..." | |
| if brew install gh; then | |
| log_success "GitHub CLI installed successfully" | |
| else | |
| log_error "Failed to install GitHub CLI" | |
| log_info "Please run: brew install gh" | |
| exit 1 | |
| fi | |
| } | |
| #============================================================================== | |
| # Step 4: GitHub Authentication | |
| #============================================================================== | |
| authenticate_github() { | |
| log_step "Step 4: GitHub Authentication" | |
| # Check if already authenticated | |
| if gh auth status &>/dev/null; then | |
| log_success "Already authenticated with GitHub" | |
| gh auth status | |
| return 0 | |
| fi | |
| log_info "You need to authenticate with GitHub to clone the support repository." | |
| log_info "This will open a browser window for authentication." | |
| echo "" | |
| log_warning "Press Enter to start GitHub authentication..." | |
| read -r | |
| # Run gh auth login interactively | |
| # Using web-based auth which is more reliable | |
| if gh auth login --web --git-protocol https; then | |
| log_success "GitHub authentication successful" | |
| else | |
| log_error "GitHub authentication failed" | |
| log_info "Please run: gh auth login" | |
| exit 1 | |
| fi | |
| } | |
| #============================================================================== | |
| # Step 5: Clone Support Repository | |
| #============================================================================== | |
| clone_support_repo() { | |
| log_step "Step 5: Clone Support Repository" | |
| # Create GITDIR if it doesn't exist | |
| if [[ ! -d "$GITDIR" ]]; then | |
| log_info "Creating directory: $GITDIR" | |
| mkdir -p "$GITDIR" | |
| fi | |
| # Check if support repository already exists | |
| if [[ -d "$SUPPORTDIR/.git" ]]; then | |
| log_success "Support repository already exists at $SUPPORTDIR" | |
| log_info "Updating repository..." | |
| (cd "$SUPPORTDIR" && git pull) || log_warning "Failed to update repository" | |
| return 0 | |
| fi | |
| # Install git-lfs first (required for support repository) | |
| if ! command_exists git-lfs; then | |
| log_info "Installing git-lfs (required for support repository)..." | |
| if brew install git-lfs; then | |
| git lfs install --skip-repo | |
| log_success "git-lfs installed" | |
| else | |
| log_warning "Failed to install git-lfs. Large files may not be available." | |
| fi | |
| else | |
| # Ensure git-lfs is initialized | |
| git lfs install --skip-repo 2>/dev/null || true | |
| fi | |
| log_info "Cloning support repository to $SUPPORTDIR..." | |
| log_info "This may take a few minutes depending on your connection speed." | |
| echo "" | |
| if gh repo clone elastic/support "$SUPPORTDIR"; then | |
| log_success "Support repository cloned successfully" | |
| # Pull LFS files | |
| if command_exists git-lfs; then | |
| log_info "Pulling git-lfs files..." | |
| (cd "$SUPPORTDIR" && git lfs pull 2>/dev/null) || log_warning "Failed to pull git-lfs files" | |
| fi | |
| else | |
| log_error "Failed to clone support repository" | |
| log_info "Please ensure you have access to https://github.com/elastic/support" | |
| exit 1 | |
| fi | |
| } | |
| #============================================================================== | |
| # Step 6: Oh My Zsh (required for power-ups) | |
| #============================================================================== | |
| install_oh_my_zsh() { | |
| log_step "Step 6: Oh My Zsh" | |
| if [[ -d "${HOME}/.oh-my-zsh" ]]; then | |
| log_success "Oh My Zsh already installed" | |
| return 0 | |
| fi | |
| if ! command_exists zsh; then | |
| log_warning "zsh not found. Oh My Zsh requires zsh (install via: brew install zsh)" | |
| return 1 | |
| fi | |
| log_info "Installing Oh My Zsh (unattended)..." | |
| if KEEP_ZSHRC=yes CHSH=no RUNZSH=no sh -c "$(curl -fsSL --max-time 60 https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended; then | |
| log_success "Oh My Zsh installed successfully" | |
| else | |
| log_warning "Oh My Zsh installation failed or was skipped. Power-ups may not install fully." | |
| log_info "You can install manually: sh -c \"\$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\"" | |
| return 1 | |
| fi | |
| } | |
| #============================================================================== | |
| # Step 7: Run install-power-ups.sh | |
| #============================================================================== | |
| run_power_ups_installer() { | |
| log_step "Step 7: Install Power-Ups" | |
| local install_script="$SUPPORTDIR/cli-addons/install-power-ups.sh" | |
| if [[ ! -f "$install_script" ]]; then | |
| log_error "install-power-ups.sh not found at $install_script" | |
| log_info "The support repository may not have been cloned correctly." | |
| exit 1 | |
| fi | |
| log_info "Running install-power-ups.sh..." | |
| echo "" | |
| # Make the script executable and run it | |
| chmod +x "$install_script" | |
| # Pass through GITDIR, SUPPORTDIR, and DEBUG | |
| GITDIR="$GITDIR" SUPPORTDIR="$SUPPORTDIR" DEBUG="$DEBUG" "$install_script" | |
| } | |
| #============================================================================== | |
| # Main Function | |
| #============================================================================== | |
| main() { | |
| parse_args "$@" | |
| echo "" | |
| echo -e "${BOLD}╔══════════════════════════════════════════════════════════════════════════╗${NC}" | |
| echo -e "${BOLD}║ ║${NC}" | |
| echo -e "${BOLD}║ Support Team Tooling Bootstrap ║${NC}" | |
| echo -e "${BOLD}║ ║${NC}" | |
| echo -e "${BOLD}╚══════════════════════════════════════════════════════════════════════════╝${NC}" | |
| echo "" | |
| echo "This script will set up your Mac with the Support Team tooling environment." | |
| echo "" | |
| echo "Configuration:" | |
| echo " GITDIR: $GITDIR" | |
| echo " SUPPORTDIR: $SUPPORTDIR" | |
| echo "" | |
| log_debug "DEBUG=$DEBUG" | |
| # Check we're on macOS | |
| check_macos | |
| # Ensure we can read from terminal for interactive prompts | |
| ensure_tty | |
| log_warning "Press Enter to continue, or Ctrl+C to abort..." | |
| read -r | |
| # Run all steps | |
| install_xcode_cli | |
| install_homebrew | |
| install_github_cli | |
| authenticate_github | |
| clone_support_repo | |
| install_oh_my_zsh | |
| run_power_ups_installer | |
| # Final message | |
| echo "" | |
| echo -e "${GREEN}${BOLD}╔══════════════════════════════════════════════════════════════════════════╗${NC}" | |
| echo -e "${GREEN}${BOLD}║ ║${NC}" | |
| echo -e "${GREEN}${BOLD}║ Bootstrap Complete! ║${NC}" | |
| echo -e "${GREEN}${BOLD}║ ║${NC}" | |
| echo -e "${GREEN}${BOLD}╚══════════════════════════════════════════════════════════════════════════╝${NC}" | |
| echo "" | |
| echo "Next steps:" | |
| echo "" | |
| echo " 1. Restart your terminal or run: source ~/.zshrc" | |
| echo "" | |
| echo " 2. Edit your private configuration:" | |
| echo " nano ~/.oh-my-zsh/custom/_privat.zsh" | |
| echo "" | |
| echo " 3. Add your API keys:" | |
| echo " - ELASTIC_ESS_KEY (from admin.found.no)" | |
| echo " - GEMINI_API_KEY (from Google Cloud Console)" | |
| echo "" | |
| echo " 4. Authenticate with Salesforce:" | |
| echo " sf org login web -s -a elastic" | |
| echo "" | |
| echo "Documentation: $SUPPORTDIR/cli-addons/README.md" | |
| echo "" | |
| exit 0 | |
| } | |
| # Run main function | |
| main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment