openwrt/package/network/services/hostapd/files/hostapd.hotplug
Piotr Dymacz 2d113f89d2 hostapd: start hostapd/wpa_supplicant for all wiphy devices
c888e17e06 ("hostapd: manage instances via procd instead of pidfile")
added procd support for managing hostapd and wpa_supplicant daemons
but at the same time limited wiphy names to 'phy*'.

This brings back initial behaviour (introduced in 60fb4c92b6 ("hostapd:
add ubus reload") and makes procd manage daemons for any wiphy device
found in '/sys/class/ieee80211'.

CC: Felix Fietkau <nbd@nbd.name>
CC: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2020-02-24 23:27:50 +01:00

47 lines
972 B
Bash

#!/bin/sh
initscript="$0"
. /lib/functions.sh
. /lib/functions/procd.sh
cd /sys/class/ieee80211
procd_lock() {
return 0
}
service_triggers() {
return 0
}
service_data() {
return 0
}
procd_open_service hostapd
for phy in *; do
[ -d "$phy" ] || continue
mkdir -p /var/run/wpa_supplicant-$phy /var/run/hostapd-$phy
if [ -x "/usr/sbin/hostapd" ]; then
procd_open_instance hostapd-$phy
procd_set_param command /usr/sbin/hostapd -s -n $phy -g /var/run/hostapd-${phy}/global
procd_set_param CREATE_TIME="$(date -r $phy)" # force restart on recreated phy
procd_set_param respawn
procd_close_instance
fi
if [ -x "/usr/sbin/wpa_supplicant" ]; then
procd_open_instance supplicant-$phy
procd_set_param command /usr/sbin/wpa_supplicant -s -n $phy -g /var/run/wpa_supplicant-${phy}/global
procd_set_param CREATE_TIME="$(date -r $phy)" # force restart on recreated phy
procd_set_param respawn
procd_close_instance
fi
done
procd_close_service set