diff --git a/application/src/components/servers/AddServerAgentDialog.tsx b/application/src/components/servers/AddServerAgentDialog.tsx index 755bb3d..65c1645 100644 --- a/application/src/components/servers/AddServerAgentDialog.tsx +++ b/application/src/components/servers/AddServerAgentDialog.tsx @@ -14,6 +14,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { getCurrentEndpoint } from "@/lib/pocketbase"; import { ServerAgentConfigForm } from "./ServerAgentConfigForm"; import { OneClickInstallTab } from "./OneClickInstallTab"; +import { DockerOneClickTab } from "./DockerOneClickTab"; import { ManualInstallTab } from "./ManualInstallTab"; interface AddServerAgentDialogProps { @@ -123,9 +124,10 @@ export const AddServerAgentDialog: React.FC = ({ - + Configure Agent One-Click Install + Docker One-Click Manual Installation @@ -150,6 +152,16 @@ export const AddServerAgentDialog: React.FC = ({ onDialogClose={handleDialogClose} /> + + + + void; +} + +export const DockerOneClickTab: React.FC = ({ + serverToken, + currentPocketBaseUrl, + formData, + serverId, + onDialogClose, +}) => { + const getDockerOneClickCommand = () => { + const scriptUrl = "https://cdn.checkcle.io/scripts/server-docker-agent.sh"; + + return `curl -L -o server-docker-agent.sh "${scriptUrl}" +chmod +x server-docker-agent.sh +SERVER_TOKEN="${serverToken}" \\ +POCKETBASE_URL="${currentPocketBaseUrl}" \\ +SERVER_NAME="${formData.serverName}" \\ +AGENT_ID="${serverId}" \\ +sudo -E bash ./server-docker-agent.sh`; + }; + + const getDirectDockerCommand = () => { + return `docker run -d \\ + --name monitoring-agent \\ + --restart unless-stopped \\ + -p 8081:8081 \\ + --group-add 999 \\ + -e AGENT_ID="${serverId}" \\ + -e SERVER_NAME="${formData.serverName}" \\ + -e SERVER_TOKEN="${serverToken}" \\ + -e POCKETBASE_URL="${currentPocketBaseUrl}" \\ + -e POCKETBASE_ENABLED=true \\ + -v /proc:/host/proc:ro \\ + -v /etc:/host/etc:ro \\ + -v /sys:/host/sys:ro \\ + -v /:/host/root:ro \\ + -v /var/run:/host/var/run:ro \\ + -v /dev:/host/dev:ro \\ + -v /var/run/docker.sock:/var/run/docker.sock:ro \\ + -v monitoring_data:/var/lib/monitoring-agent \\ + -v monitoring_logs:/var/log/monitoring-agent \\ + operacle/checkcle-server-agent:latest`; + }; + + const handleCopyOneClickCommand = async (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + console.log('Copy one-click command button clicked'); + const command = getDockerOneClickCommand(); + console.log('Copying one-click command:', command); + await copyToClipboard(command); + }; + + const handleCopyDockerCommand = async (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + console.log('Copy docker command button clicked'); + const command = getDirectDockerCommand(); + console.log('Copying docker command:', command); + await copyToClipboard(command); + }; + + return ( +
+ {/* One-Click Docker Installation */} + + + + + Docker One-Click Install (Recommended) + + + Automated Docker container installation with system monitoring capabilities + + + +
+ +
+
+                {getDockerOneClickCommand()}
+              
+ +
+
+ +
+

This script will automatically:

+
    +
  1. Download and setup the Docker monitoring agent
  2. +
  3. Configure all required environment variables
  4. +
  5. Start the container with proper system access
  6. +
  7. Setup monitoring data persistence
  8. +
+
+
+
+ + {/* Direct Docker Run Command */} + + + + + Direct Docker Run Command + + + If you prefer to run the Docker container directly without the script + + + +
+ +
+
+                {getDirectDockerCommand()}
+              
+ +
+
+ +
+

Prerequisites for direct Docker run:

+
    +
  1. Docker must be installed and running
  2. +
  3. The operacle/checkcle-server-agent image must be available
  4. +
  5. Run as root or with sudo privileges
  6. +
+
+
+
+ +
+ +
+
+ ); +}; \ No newline at end of file