From 915bef2dd48aaa9432b88a9682456147eeac7f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Sat, 7 Jun 2025 09:49:52 +0200 Subject: [PATCH] udev: Rename all wlan interfaces wifiN and start scanning This since the feature is called 'wifi' in Infix, this makes the naming consistent over the system. Also trigger start of a wpa_supplicant, for scanning in the background. The scanning results is available operational. --- .../etc/udev/rules.d/70-rename-wifi.rules | 1 + src/confd/bin/wifi-detected.sh | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 board/common/rootfs/etc/udev/rules.d/70-rename-wifi.rules create mode 100755 src/confd/bin/wifi-detected.sh diff --git a/board/common/rootfs/etc/udev/rules.d/70-rename-wifi.rules b/board/common/rootfs/etc/udev/rules.d/70-rename-wifi.rules new file mode 100644 index 00000000..4251fadf --- /dev/null +++ b/board/common/rootfs/etc/udev/rules.d/70-rename-wifi.rules @@ -0,0 +1 @@ +SUBSYSTEM=="net", ACTION=="add", TEST=="/sys/class/net/$name/wireless", NAME="wifi%n" diff --git a/src/confd/bin/wifi-detected.sh b/src/confd/bin/wifi-detected.sh new file mode 100755 index 00000000..079d2ba7 --- /dev/null +++ b/src/confd/bin/wifi-detected.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ ! -e "/etc/wpa-supplicant-${INTERFACE}.conf" ]; then + cat < /etc/wpa-supplicant-${INTERFACE}.conf +ctrl_interface=/run/wpa_supplicant +update_config=0 +autoscan=periodic:10 +disable_scan_offload=1 +ap_scan=1 +# Empty network block to enable scanning without connecting +bgscan="simple: 30:-45:300" + +EOF + cat < /etc/finit.d/available/wpa-supplicant-${INTERFACE}.conf +# Generated by Infix wifi interface detected +service name:wpa_supplicant :${INTERFACE} <> \ + [2345] wpa_supplicant -s -i ${INTERFACE} -c /etc/wpa-supplicant-${INTERFACE}.conf \ + -- WPA supplicant @${INTERFACE} (scanning only) + +EOF + initctl -bfqn enable wpa-supplicant-${INTERFACE} + initctl reload + TIMEOUT=300 + status=$(wpa_cli -i ${INTERFACE} scan) + while [ "$status" != "OK" ]; do + status=$(wpa_cli -i ${INTERFACE} scan) + TIMEOUT=$((TIMEOUT-1)) + [ $TIMEOUT -eq 0 ] && logger -t wifi-detect "Failed to start scanning on $INTERFACE" && break + sleep 0.5 + done +fi