#!/bin/bash
# Script to block Nuke/Foundry telemetry

echo "=== Nuke Telemetry Blocker ==="
echo ""
echo "This script will block Nuke from sending telemetry data to Foundry servers."
echo "WARNING: This may affect Help menu and other online features."
echo ""
read -p "Continue? (y/n): " confirm

if [ "$confirm" != "y" ]; then
    echo "Aborted."
    exit 0
fi

echo ""
echo "Backing up /etc/hosts..."
sudo cp /etc/hosts /etc/hosts.backup.$(date +%Y%m%d_%H%M%S)

echo "Adding Foundry domains to /etc/hosts..."
sudo bash -c 'cat >> /etc/hosts << HOSTS

# Block Nuke/Foundry Telemetry (added $(date))
127.0.0.1 api.honeycomb.io
127.0.0.1 learn.foundry.com  
127.0.0.1 sentry.foundry.com
HOSTS
'

echo ""
echo "✓ Domains blocked in /etc/hosts"
echo ""
echo "Testing blocks..."
ping -c 1 api.honeycomb.io 2>&1 | head -2
ping -c 1 learn.foundry.com 2>&1 | head -2

echo ""
echo "=== DONE ==="
echo ""
echo "Nuke telemetry should now be blocked."
echo "If you experience issues, restore your hosts file:"
echo "  sudo cp /etc/hosts.backup.* /etc/hosts"
echo ""
echo "To unblock, edit /etc/hosts and remove the Foundry entries:"
echo "  sudo nano /etc/hosts"
