54 lines
2.0 KiB
Bash
54 lines
2.0 KiB
Bash
#!/bin/bash
|
|
|
|
# Test script to verify the installation command generation fixes
|
|
|
|
echo "=== Testing RedFlag Agent Installation Command Generation ==="
|
|
echo
|
|
|
|
# Test 1: Verify the API endpoint exists and is accessible
|
|
echo "1. Testing API endpoint availability..."
|
|
if curl -sfL "http://localhost:8080/api/v1/install/linux" > /dev/null 2>&1; then
|
|
echo "✓ API endpoint /api/v1/install/linux is accessible"
|
|
else
|
|
echo "⚠ API endpoint not accessible (server may not be running)"
|
|
fi
|
|
echo
|
|
|
|
# Test 2: Show examples of corrected commands
|
|
echo "2. Corrected Installation Commands:"
|
|
echo "-----------------------------------"
|
|
echo
|
|
echo "For Registration Token API (when creating a new token):"
|
|
echo 'curl -sfL "http://localhost:8080/api/v1/install/linux?token=YOUR_TOKEN_HERE" | sudo bash'
|
|
echo
|
|
|
|
echo "For Agent Settings UI (Linux):"
|
|
echo 'curl -sfL "http://localhost:8080/api/v1/install/linux?token=YOUR_TOKEN_HERE" | sudo bash'
|
|
echo
|
|
|
|
echo "For Agent Settings UI (Windows PowerShell):"
|
|
echo 'iwr "http://localhost:8080/api/v1/install/windows?token=YOUR_TOKEN_HERE" -OutFile install.bat; .\install.bat'
|
|
echo
|
|
|
|
# Test 3: Verify template variables
|
|
echo "3. Template Variables Check:"
|
|
echo "-----------------------------"
|
|
echo "The following variables are now provided to the install template:"
|
|
echo "- AgentUser: redflag-agent"
|
|
echo "- AgentHome: /var/lib/redflag-agent"
|
|
echo "- ConfigDir: /etc/redflag"
|
|
echo "- LogDir: /var/log/redflag"
|
|
echo
|
|
|
|
echo "=== Summary of Fixes ==="
|
|
echo "✓ Fixed registration token API command generation"
|
|
echo "✓ Fixed agent settings UI command generation (both TokenManagement and AgentManagement)"
|
|
echo "✓ Fixed template error by adding .AgentUser and related variables"
|
|
echo "✓ Changed from command-line args to query parameters for token passing"
|
|
echo "✓ Added proper protocol handling (http:// for localhost)"
|
|
echo "✓ Added sudo to the bash command for proper permissions"
|
|
echo
|
|
|
|
echo "All installation commands now use the correct format:"
|
|
echo 'curl -sfL "http://localhost:8080/api/v1/install/linux?token=<TOKEN>" | sudo bash'
|
|
echo |