c319d42c1a6e17154b11af804fb0ba6767abace0
[openwrt/staging/mkresin.git] / package / network / services / hostapd / files / hostapd.hotplug
1 #!/bin/sh
2
3 initscript="$0"
4
5 . /lib/functions.sh
6 . /lib/functions/procd.sh
7
8 cd /sys/class/ieee80211
9
10 procd_lock() {
11 return 0
12 }
13
14 service_triggers() {
15 return 0
16 }
17
18 service_data() {
19 return 0
20 }
21
22 procd_open_service hostapd
23
24 for phy in phy*; do
25 [ -d "$phy" ] || continue
26
27 mkdir -p /var/run/wpa_supplicant-$phy /var/run/hostapd-$phy
28
29 if [ -x "/usr/sbin/hostapd" ]; then
30 procd_open_instance hostapd-$phy
31 procd_set_param command /usr/sbin/hostapd -s -n $phy -g /var/run/hostapd-${phy}/global
32 procd_set_param CREATE_TIME="$(date -r $phy)" # force restart on recreated phy
33 procd_set_param respawn
34 procd_close_instance
35 fi
36
37 if [ -x "/usr/sbin/wpa_supplicant" ]; then
38 procd_open_instance supplicant-$phy
39 procd_set_param command /usr/sbin/wpa_supplicant -s -n $phy -g /var/run/wpa_supplicant-${phy}/global
40 procd_set_param CREATE_TIME="$(date -r $phy)" # force restart on recreated phy
41 procd_set_param respawn
42 procd_close_instance
43 fi
44 done
45
46 procd_close_service set