forked from NilsRo/Openwrt-radio-check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
radio-check.sh
38 lines (32 loc) · 922 Bytes
/
radio-check.sh
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
#!/bin/sh
# Universal radio check script by Ashus (2023)
# source: https://github.com/Ashus/OpenWRT-radio-check
. /usr/share/libubox/jshn.sh
check_and_restart_radio_iface() {
local radio="$1"
local iface="$2"
check=$(iw dev $iface info|awk '/channel/{print $2}')
if [[ -z $check ]]
then
logger -p notice -t radio_check "Wifi '$radio'/'$iface' restart because of DFS bug!"
wifi down $radio
sleep 2
wifi up $radio
else
if [[ "$(uci get wireless.$radio.channel)" -ne $check ]]
then
logger -p notice -t radio_check "Wifi '$radio'/'$iface' restart because of channel!"
wifi down $radio
sleep 2
wifi up $radio
fi
fi
}
wirelessconfig="$(ubus call network.wireless status)"
json_init
json_load "$wirelessconfig"
json_get_keys radios
for radio in $radios; do
iface=$(jsonfilter -s "$wirelessconfig" -e "@.$radio.interfaces[0].ifname")
check_and_restart_radio_iface "$radio" "$iface"
done