mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-14 21:10:11 +01:00
inteno-netmodes: make sure netmode-handler and netmode-conf do not try to switch mode simultaneously
This commit is contained in:
parent
e9d413e2db
commit
885baef845
3 changed files with 35 additions and 9 deletions
|
|
@ -48,14 +48,28 @@ is_inteno_macaddr()
|
|||
switch_mode() {
|
||||
[ "$repeaterready" == "1" ] || return
|
||||
|
||||
defroute=$(ip r | grep default | awk '{print$3}')
|
||||
ping -c 1 -W 1 $defroute >/dev/null 2>&1
|
||||
uplinkmac=$(grep "$defroute" /proc/net/arp | awk '{print$4}')
|
||||
|
||||
# will be auto-configured if the uplink device is Inteno
|
||||
is_inteno_macaddr $uplinkmac && return
|
||||
# flush iptables in case the MASTER
|
||||
# tries to configure us before
|
||||
# firewall is disabled the proper way
|
||||
iptables -F
|
||||
|
||||
ubus call leds set '{"state" : "allflash"}'
|
||||
|
||||
local ret=0
|
||||
# let netmode-conf up to 20 seconds before switching mode
|
||||
for tm in 2 4 6 8; do
|
||||
if [ -f /tmp/wificontrol.txt ]; then
|
||||
ret=1
|
||||
break
|
||||
fi
|
||||
sleep $tm
|
||||
done
|
||||
|
||||
# let netmode-conf take over
|
||||
[ $ret -eq 1 ] && return
|
||||
|
||||
# go head with switching mode
|
||||
touch -f /tmp/switching_mode
|
||||
echo "Switching to 'extender' mode" > /dev/console
|
||||
uci -q set netmode.setup.curmode='repeater'
|
||||
uci set netmode.setup.repeaterready=0
|
||||
|
|
@ -66,6 +80,7 @@ switch_mode() {
|
|||
wifi reload nodat
|
||||
ubus call router.network reload
|
||||
ubus call leds set '{"state" : "normal"}'
|
||||
rm -f /tmp/switching_mode
|
||||
}
|
||||
|
||||
test_ip() {
|
||||
|
|
|
|||
|
|
@ -207,13 +207,16 @@ switch_netmode() {
|
|||
}
|
||||
|
||||
start_client_listener() {
|
||||
local curmode repeaterready
|
||||
config_load netmode
|
||||
local curmode repeaterready ulcpid
|
||||
|
||||
config_load netmode
|
||||
config_get repeaterready setup repeaterready 0
|
||||
|
||||
ulcpid=$(ps | grep "ubus listen client" | grep -v grep | awk '{print$1}')
|
||||
|
||||
[ $repeaterready -eq 1 ] && {
|
||||
killall -SIGKILL netmode-client-detect >/dev/null 2>&1
|
||||
kill -9 $ulcpid >/dev/null 2>&1
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -222,6 +225,7 @@ start_client_listener() {
|
|||
case "$curmode" in
|
||||
repeater*)
|
||||
killall -SIGKILL netmode-client-detect >/dev/null 2>&1
|
||||
kill -9 $ulcpid >/dev/null 2>&1
|
||||
;;
|
||||
*)
|
||||
pidof netmode-client-detect || /sbin/netmode-client-detect &
|
||||
|
|
|
|||
|
|
@ -108,9 +108,16 @@ backup() {
|
|||
file="$1"
|
||||
from_gui="$2"
|
||||
|
||||
|
||||
[ -f "$file" ] || exit
|
||||
|
||||
# let netmode-handler up to 20 seconds to finish switching mode
|
||||
for tm in 2 4 6 8; do
|
||||
if [ ! -f /tmp/switching_mode ]; then
|
||||
break
|
||||
fi
|
||||
sleep $tm
|
||||
done
|
||||
|
||||
[ "$from_gui" == "true" ] && backup
|
||||
|
||||
json_load "`cat $file`"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue