#!/bin/bash set -euo pipefail # Prodactive Agent Installer - Linux SERVER_URL="https://agent.prodactive.app" API_KEY="29ef8f22b694089df98a20e473685ef31a6d215ca75a74ca2b5e3f4fe7f433a1" INSTALL_DIR="/opt/prodactive-agent" BIN_PATH="$INSTALL_DIR/prodactive-agent" CONFIG_PATH="/etc/prodactive/config.toml" SERVICE_NAME="prodactive-agent" if [ "$(id -u)" -ne 0 ]; then echo "ERROR: Run with sudo." echo " curl -fsSL '$SERVER_URL/install/script/linux' | sudo bash" exit 1 fi echo "" echo " Prodactive Agent Installer (Linux)" echo " ===================================" echo "" mkdir -p "$INSTALL_DIR" /etc/prodactive echo " [1/4] Stopping existing agent..." systemctl stop "$SERVICE_NAME" 2>/dev/null || true sleep 1 echo " [2/4] Downloading agent..." curl -fsSL -o "$BIN_PATH" "$SERVER_URL/install/download/linux" 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 systemd service..." cat > "/etc/systemd/system/$SERVICE_NAME.service" << SVC [Unit] Description=Prodactive Monitoring Agent After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=$BIN_PATH Restart=always RestartSec=10 Environment=DISPLAY=:0 [Install] WantedBy=multi-user.target SVC systemctl daemon-reload systemctl enable "$SERVICE_NAME" systemctl start "$SERVICE_NAME" echo "" echo " Installed successfully!" echo " Server: $SERVER_URL" echo " Agent will start automatically on boot." echo " Status: systemctl status $SERVICE_NAME" echo ""