#!/bin/bash
# Simple CLI Network Configuration Script
# Based on Aurora's network configuration pattern

set -euo pipefail

echo "=== Configuring Network ==="

# Enable network services
echo "Enabling network services..."
systemctl enable systemd-networkd
systemctl enable systemd-resolved

# Configure network interfaces
echo "Configuring network interfaces..."
cat > /etc/systemd/network/10-eth0.network << EOF
[Match]
Name=eth0

[Network]
DHCP=yes
IPv6AcceptRA=yes
EOF

# Configure wireless if available
if [ -d /sys/class/net/wlan0 ]; then
    echo "Configuring wireless network..."
    cat > /etc/systemd/network/25-wireless.network << EOF
[Match]
Name=wlan0

[Network]
DHCP=yes
IPv6AcceptRA=yes
EOF
fi

# Configure DNS
echo "Configuring DNS..."
cat > /etc/systemd/resolved.conf << EOF
[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1 1.0.0.1
EOF

# Start network services
echo "Starting network services..."
systemctl start systemd-networkd
systemctl start systemd-resolved

echo "=== Network configuration complete ==="
echo "Network services are running"
