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.
This commit is contained in:
Mattias Walström
2025-06-19 15:23:24 +02:00
parent 7f9a1df6f7
commit 915bef2dd4
2 changed files with 32 additions and 0 deletions
@@ -0,0 +1 @@
SUBSYSTEM=="net", ACTION=="add", TEST=="/sys/class/net/$name/wireless", NAME="wifi%n"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/sh
if [ ! -e "/etc/wpa-supplicant-${INTERFACE}.conf" ]; then
cat <<EOF > /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 <<EOF > /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