export wifi_iface=$(ls /sys/class/net 2>/dev/null | grep -E "^(wl|wlan|wlp)" | head -1)

if [ -z "$wifi_iface" ]; then
  echo "No Wi‑Fi interface found – skipping configuration."
  exit 0
fi

echo "Configuring Wi‑Fi on $wifi_iface"

envsubst < /cdrom/nocloud/user-data-wifi.config > /target/etc/netplan/99-wifi.yaml
chmod 600 /target/etc/netplan/99-wifi.yaml

# chroot /target netplan generate
