#!/bin/bash
# NIP Uninstallation Script
set -e

echo "🗑️  Uninstalling NIP"
echo "======================"
echo ""

# Check if running as root
if [ "$EUID" -ne 0 ]; then
    echo "⚠️  This uninstaller requires root privileges"
    echo "   Please run: sudo ./uninstall.sh"
    exit 1
fi

# Remove binary
echo "📦 Removing NIP binary..."
rm -f /usr/local/bin/nip
echo "   Removed: /usr/local/bin/nip"
echo ""

# Ask about data removal
echo "❓ Remove NIP data directories? [y/N]"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
    echo "🗑️  Removing data directories..."
    rm -rf /Programs
    rm -rf /System/Links
    rm -rf /var/nip
    rm -rf /etc/nip
    rm -f /etc/profile.d/nip.sh
    rm -f /etc/ld.so.conf.d/nip.conf
    echo "   Removed all NIP data"
else
    echo "   Kept NIP data directories"
fi
echo ""

echo "✅ NIP uninstallation complete!"
