#!/bin/sh
# /usr/bin/nyn-device-info
# Helper script to get device information for NYN configuration

echo "Available network devices:"
echo "=========================="

if command -v nyn >/dev/null 2>&1; then
    nyn -mode info 2>/dev/null | grep -E "(Found|device|hardware_description)" | while read line; do
        echo "$line"
    done
else
    echo "NYN binary not found. Showing available network interfaces:"
    for dev in /sys/class/net/*; do
        if [ -d "$dev" ]; then
            iface=$(basename "$dev")
            if [ "$iface" != "lo" ]; then
                echo "Device: $iface"
                if [ -f "$dev/address" ]; then
                    echo "  MAC: $(cat "$dev/address")"
                fi
                if [ -f "$dev/operstate" ]; then
                    echo "  State: $(cat "$dev/operstate")"
                fi
                echo ""
            fi
        fi
    done
fi
