-
Notifications
You must be signed in to change notification settings - Fork 12
/
initscript
executable file
·54 lines (43 loc) · 1.6 KB
/
initscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh /etc/rc.common
#file: /etc/init.d/rrm_nr
## Based on: https://forum.openwrt.org/t/how-does-rrm-work/32635/68
START=99
NAME=rrm_nr
USE_PROCD=1
start_service() {
#[ ! -f /etc/config/wireless ] && logger -t "${NAME}" -pdaemon.error "/etc/config/wireless does not exist" && exit 1
#[ $(grep -q 'wifi-iface' /etc/config/wireless) ] && logger -t "${NAME}" -pdaemon.error "/etc/config/wireless does not have any wifi-iface stanzas" && exit 1
local rrm_own
#todo skip if nr is disabled for interface, skip disabled interface etc.
#while [ "$(ubus list hostapd.* | wc -l)" != "$(grep 'wifi-iface' /etc/config/wireless | wc -l)" ]; do
# logger -t "${NAME}" -pdaemon.info "Waiting for all interfaces to initialize"
# sleep 30
#done
OIFS=$IFS
IFS=$'\x0a'
local ssid_count=1
for value in $(ubus list hostapd.*); do
curr_value=$(/bin/ubus call "${value}" rrm_nr_get_own | /usr/bin/jsonfilter -e '$.value')
# Using + as the delimiter instead of |. Because + is an invalid character to use in SSID naming,
# this removes the known issue where | could not be used in the SSID name.
rrm_own="${rrm_own}+SSID${ssid_count}=${curr_value}"
ssid_count=$((ssid_count + 1))
done
rrm_own="${rrm_own#*+}"
IFS='+'
set -- $rrm_own
IFS=$OIFS
procd_open_instance
procd_set_param term_timeout 5
procd_set_param command /bin/sh "/usr/bin/rrm_nr"
#https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=5247
procd_add_mdns "rrm_nr" "udp" "5247" "$@"
procd_close_instance
}
boot() {
sleep 30
start
}
service_triggers() {
procd_add_reload_trigger "network" "wireless"
}