#!/bin/bash
set -e

# Detect architecture
ARCH=$(uname -m)
DOWNLOAD_URL=""

if [ "$ARCH" = "x86_64" ]; then
    DOWNLOAD_URL="https://get.north.sh/download/linux-amd64"
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
    DOWNLOAD_URL="https://get.north.sh/download/linux-arm64"
else
    echo "Unsupported architecture: $ARCH"
    exit 1
fi

# Create config file
cat > config.json << 'EOL'
{
  "remoteServerUrl": "https://north.sh",
  "websocketUrl": "https://north.sh:8080",
  "remoteServerAppKey": "",
  "sourceId": "sitemap.xml",
  "secretKey": "",
  "debug": true,
  "workers": 10,
  "bufferSize": 100,
  "telemetry": false
}
EOL

# Download and set permissions
echo "Downloading SIEM agent..."
curl -L -o siem-agent "$DOWNLOAD_URL"
chmod +x siem-agent

echo "Installation complete! Run with: ./siem-agent -c config.json"
