#!/bin/bash # GuruRMM Agent Installer for macOS # Usage: curl -fsSL https://rmm.azcomputerguru.com/downloads/install-mac.sh | sudo bash -s -- --site-id SITE_ID set -e SITE_ID="" ARCH=$(uname -m) # Parse arguments while [[ $# -gt 0 ]]; do case $1 in --site-id) SITE_ID="$2" shift 2 ;; *) echo "Unknown option: $1" exit 1 ;; esac done if [ -z "$SITE_ID" ]; then echo "Error: --site-id required" echo "Usage: curl -fsSL https://rmm.azcomputerguru.com/downloads/install-mac.sh | sudo bash -s -- --site-id SITE_ID" exit 1 fi echo "Installing GuruRMM Agent..." echo "Site ID: $SITE_ID" echo "Architecture: $ARCH" # Determine download URL based on architecture if [ "$ARCH" = "arm64" ]; then DOWNLOAD_URL="https://rmm.azcomputerguru.com/downloads/gururmm-agent-macos-arm64-latest" elif [ "$ARCH" = "x86_64" ]; then DOWNLOAD_URL="https://rmm.azcomputerguru.com/downloads/gururmm-agent-macos-amd64-latest" else echo "Error: Unsupported architecture: $ARCH" exit 1 fi # Download agent echo "Downloading agent..." curl -fsSL -o /usr/local/bin/gururmm-agent "$DOWNLOAD_URL" chmod 755 /usr/local/bin/gururmm-agent # Create config directory and site.plist echo "Creating configuration..." mkdir -p /usr/local/etc/gururmm cat > /usr/local/etc/gururmm/site.plist < SiteId $SITE_ID EOF # Create LaunchDaemon echo "Installing service..." cat > /Library/LaunchDaemons/com.azcomputerguru.gururmm-agent.plist < Label com.azcomputerguru.gururmm-agent ProgramArguments /usr/local/bin/gururmm-agent run RunAtLoad KeepAlive StandardOutPath /Library/Logs/GuruRMM/stdout.log StandardErrorPath /Library/Logs/GuruRMM/stderr.log EOF # Create log directory mkdir -p /Library/Logs/GuruRMM # Stop existing service if running if launchctl list | grep -q com.azcomputerguru.gururmm-agent; then echo "Stopping existing service..." launchctl unload /Library/LaunchDaemons/com.azcomputerguru.gururmm-agent.plist 2>/dev/null || true sleep 2 fi # Load and start service echo "Starting service..." launchctl load /Library/LaunchDaemons/com.azcomputerguru.gururmm-agent.plist launchctl start com.azcomputerguru.gururmm-agent echo "" echo "✓ GuruRMM Agent installed successfully!" echo "" echo "Check status: sudo launchctl list | grep gururmm" echo "View logs: sudo tail -f /Library/Logs/GuruRMM/agent.log.*"