#!/bin/bash # # GuruRMM Agent Installer # # Usage: # curl -fsSL https://rmm.azcomputerguru.com/install.sh | sudo bash -s -- --api-key YOUR_KEY # # Or download and run locally: # ./install.sh --server-url wss://rmm-api.example.com/ws --api-key YOUR_KEY # set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Default values DOWNLOAD_URL="${GURURMM_DOWNLOAD_URL:-https://rmm.azcomputerguru.com/downloads/gururmm-agent-linux-amd64}" SERVER_URL="" API_KEY="" SKIP_LEGACY_CHECK="" TMP_DIR="" # Cleanup function cleanup() { if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then rm -rf "$TMP_DIR" fi } trap cleanup EXIT # Print colored message info() { echo -e "${GREEN}[INFO]${NC} $1" } warn() { echo -e "${YELLOW}[WARN]${NC} $1" } error() { echo -e "${RED}[ERROR]${NC} $1" exit 1 } # Show usage usage() { cat < /dev/null; then missing="$missing $cmd" fi done if [ -n "$missing" ]; then error "Missing required commands:$missing" fi } # Download the agent binary download_agent() { local platform="$1" local dest="$2" # Adjust download URL for platform if not overridden local url="$DOWNLOAD_URL" if [[ "$DOWNLOAD_URL" == *"linux-amd64"* ]]; then url="${DOWNLOAD_URL/linux-amd64/$platform}" fi info "Downloading agent from: $url" if ! curl -fsSL -o "$dest" "$url"; then error "Failed to download agent binary" fi chmod +x "$dest" info "Downloaded to: $dest" } # Main installation main() { info "GuruRMM Agent Installer" info "======================" check_dependencies local platform platform=$(detect_platform) info "Detected platform: $platform" # Create temp directory TMP_DIR=$(mktemp -d) local agent_binary="$TMP_DIR/gururmm-agent" # Download the agent download_agent "$platform" "$agent_binary" # Build install command local install_cmd="$agent_binary install" if [ -n "$SERVER_URL" ]; then install_cmd="$install_cmd --server-url \"$SERVER_URL\"" fi install_cmd="$install_cmd --api-key \"$API_KEY\"" if [ -n "$SKIP_LEGACY_CHECK" ]; then install_cmd="$install_cmd $SKIP_LEGACY_CHECK" fi info "Running installation..." # Execute install command eval "$install_cmd" info "" info "Installation complete!" info "" info "Check agent status with:" info " sudo systemctl status gururmm-agent" info "" info "View logs with:" info " sudo journalctl -u gururmm-agent -f" } main "$@"