import React, { useState } from 'react'; import axios from 'axios'; import './ClientDownload.css'; const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:3001'; function ClientDownload({ onClose }) { const [serverId, setServerId] = useState(''); const [serverUrl, setServerUrl] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [success, setSuccess] = useState(false); // Get the base server URL for curl command (where the API is hosted) const getBaseUrl = () => { // Use serverUrl if provided, otherwise default to current origin but replace port 3000 with 3001 if (serverUrl) { return serverUrl; } return window.location.origin.replace(':3000', ':3001'); }; // Generate curl command const getCurlCommand = () => { const baseUrl = getBaseUrl(); // Include serverUrl query parameter if a custom serverUrl was provided const queryParam = serverUrl ? `?serverUrl=${encodeURIComponent(serverUrl)}` : ''; return `curl -s ${baseUrl}/api/download-client/${serverId}${queryParam} | bash`; }; const copyCurlCommand = () => { navigator.clipboard.writeText(getCurlCommand()); }; const handleDownload = async (e) => { e.preventDefault(); setLoading(true); setError(null); setSuccess(false); try { const response = await axios.post( `${API_URL}/api/download-client`, { serverId: serverId || `server-${Date.now()}`, serverUrl: serverUrl || window.location.origin.replace(':3000', ':3001') }, { responseType: 'blob' } ); // Create download link const url = window.URL.createObjectURL(new Blob([response.data])); const link = document.createElement('a'); link.href = url; link.setAttribute('download', `oculog-client-install.sh`); document.body.appendChild(link); link.click(); link.remove(); window.URL.revokeObjectURL(url); setSuccess(true); setTimeout(() => { setSuccess(false); if (onClose) onClose(); }, 3000); } catch (err) { setError(err.response?.data?.error || 'Failed to generate client package'); } finally { setLoading(false); } }; return (

Download Client

Generate a pre-configured client installer for your Ubuntu server. The installer includes your server URL and API key automatically configured.

setServerId(e.target.value)} placeholder="my-ubuntu-server" required /> Unique identifier for this server
setServerUrl(e.target.value)} placeholder="http://your-server-ip:3001" /> Leave empty to use current server
{error &&
{error}
} {success && (
Client installer downloaded! Run it on your Ubuntu server with: sudo bash oculog-client-install.sh
)}
{/* Curl Installation Instructions */}

Quick Install with curl

Copy and paste this command directly into your Ubuntu server terminal:

{serverId ? getCurlCommand() : 'curl -s SERVER_URL/api/download-client/SERVER_ID?serverUrl=SERVER_URL | bash'} {serverId && ( )}

Fill in the Server ID field above to generate your custom curl command. The command will automatically use your Server URL if provided.

Manual Installation Instructions

  1. Download the installer script above
  2. Transfer it to your Ubuntu server
  3. Make it executable: chmod +x oculog-client-install.sh
  4. Run as root: sudo ./oculog-client-install.sh
  5. The client will automatically start and begin sending metrics
); } export default ClientDownload;