#!/bin/bash set -euo pipefail # Prodactive Agent Installer - macOS SERVER_URL="https://agent.prodactive.app" API_KEY="29ef8f22b694089df98a20e473685ef31a6d215ca75a74ca2b5e3f4fe7f433a1" INSTALL_DIR="/Library/Prodactive" BIN_PATH="$INSTALL_DIR/prodactive-agent" CONFIG_PATH="$INSTALL_DIR/config.toml" PLIST_NAME="com.prodactive.agent" PLIST_PATH="/Library/LaunchDaemons/$PLIST_NAME.plist" if [ "$(id -u)" -ne 0 ]; then echo "ERROR: Run with sudo." echo " curl -fsSL '$SERVER_URL/install/script/macos' | sudo bash" exit 1 fi echo "" echo " Prodactive Agent Installer (macOS)" echo " ===================================" echo "" mkdir -p "$INSTALL_DIR" echo " [1/4] Stopping existing agent..." launchctl unload "$PLIST_PATH" 2>/dev/null || true pkill -f prodactive-agent 2>/dev/null || true sleep 1 echo " [2/4] Downloading agent..." curl -fsSL -o "$BIN_PATH" "$SERVER_URL/install/download/macos" chmod +x "$BIN_PATH" SIZE=$(du -h "$BIN_PATH" | cut -f1) echo " Downloaded: $SIZE" echo " [3/4] Writing configuration..." HOSTNAME=$(hostname -s) cat > "$CONFIG_PATH" << CONF worker_name = "$HOSTNAME" api_port = 47842 screenshot_interval_secs = 60 activity_report_interval_secs = 10 screenshot_quality = 75 max_screenshot_dimension = 1920 [cloud] server_url = "$SERVER_URL" api_key = "$API_KEY" push_interval_secs = 10 screenshot_push_interval_secs = 60 CONF chmod 600 "$CONFIG_PATH" echo " [4/4] Installing launch daemon..." cat > "$PLIST_PATH" << PLIST Label $PLIST_NAME ProgramArguments $BIN_PATH RunAtLoad KeepAlive StandardOutPath /var/log/prodactive-agent.log StandardErrorPath /var/log/prodactive-agent.log PLIST chmod 644 "$PLIST_PATH" launchctl load "$PLIST_PATH" echo "" echo " Installed successfully!" echo " Server: $SERVER_URL" echo " Agent will start automatically on boot." echo ""