diff options
author | Felix Fietkau <nbd@nbd.name> | 2019-12-05 00:26:53 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2019-12-08 19:52:38 +0100 |
commit | c888e17e067edf36c4dc798771479170003f967d (patch) | |
tree | 044c248915ee5e431a8a375e68a1310fdecb0e94 | |
parent | 4225b83a76b86b7722609347f6e8a7f9433e1ea0 (diff) | |
download | upstream-c888e17e067edf36c4dc798771479170003f967d.tar.gz upstream-c888e17e067edf36c4dc798771479170003f967d.tar.bz2 upstream-c888e17e067edf36c4dc798771479170003f967d.zip |
hostapd: manage instances via procd instead of pidfile
Allows graceful restart of crashing hostapd/wpa_supplicant instances
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
[daniel@makrotopia.org: attempt to launch only present services]
-rw-r--r-- | package/network/services/hostapd/files/hostapd.hotplug | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/package/network/services/hostapd/files/hostapd.hotplug b/package/network/services/hostapd/files/hostapd.hotplug index d568b3c85a..c319d42c1a 100644 --- a/package/network/services/hostapd/files/hostapd.hotplug +++ b/package/network/services/hostapd/files/hostapd.hotplug @@ -1,14 +1,46 @@ #!/bin/sh -[ ${ACTION} = "remove" -a -n "${DEVICENAME}" ] && { - kill $(cat /var/run/hostapd-${DEVICENAME}.pid) - rm -rf /var/run/hostapd-${DEVICENAME}.pid /var/run/hostapd-${DEVICENAME}/ - kill $(cat /var/run/wpa_supplicant-${DEVICENAME}.pid) - rm -rf /var/run/wpa_supplicant-${DEVICENAME}.pid /var/run/wpa_supplicant-${DEVICENAME}/ +initscript="$0" + +. /lib/functions.sh +. /lib/functions/procd.sh + +cd /sys/class/ieee80211 + +procd_lock() { + return 0 } -[ ${ACTION} = "add" -a -n "${DEVICENAME}" ] && { - /usr/sbin/hostapd -s -n ${DEVICENAME} -P /var/run/hostapd-${DEVICENAME}.pid -g /var/run/hostapd-${DEVICENAME}/global -B & - mkdir -p /var/run/wpa_supplicant-${DEVICENAME} - /usr/sbin/wpa_supplicant -s -n ${DEVICENAME} -P /var/run/wpa_supplicant-${DEVICENAME}.pid -g /var/run/wpa_supplicant-${DEVICENAME}/global -B & +service_triggers() { + return 0 } + +service_data() { + return 0 +} + +procd_open_service hostapd + +for phy in phy*; 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 |