USB Tethering / wifi client auto swap

Hi all !
On GL-MT300N-V2 FW 3.102, i want to be able to connect 2 internet sources : Wifi client (wwan) et usb tethering (ios 13 still !). I wish to activate only tethering when iphone plugged on USB, so that wifi client (repeater) switches OFF.
By searching forum, I found these usefull commands from Kyson-lok which works great, done manually in SSH only :
uci set glconfig.repeater.autoconnect=‘0’
uci commit glconfig
uci set wireless.sta.disabled=‘1’
uci commit
wifi restart

When Tethering gets disconnected, i want to bring back live that wifi repeater.

Could you help me to create that script in bash, to put in rc.local ?

Changing adapter in etc/config/network and etc/config/mwan3 priority does not solve this because wifi client still have a working internet connection even if slow and I could see that during my testing with slow ping time.

I also found this mwan3.user.sh but without success :

Thank you

Hi all, I answer to my own topic. Got it fixed, hope this can help others. I launch this script every minute in cron.

script to shutdown wifi client automatically

if (ifconfig eth1 | grep -q “Link encap”); then
if (ip link show apcli0 | grep -q “apcli0: <BROADCAST,MULTICAST,UP”); then
echo “Tethering up → wifi OFF”
uci set glconfig.repeater.autoconnect=‘0’
uci commit glconfig
uci set wireless.sta.disabled=‘1’
uci commit
wifi restart
fi
fi

script to relaunch wifi client automatically

if (ip link show apcli0 | grep -q “apcli0: <BROADCAST,MULTICAST>”); then
if !(ip a show | grep -q “eth1”); then
echo “Tethering down → wifi ON”
uci set glconfig.repeater.autoconnect=‘1’
uci commit glconfig
uci set wireless.sta.disabled=‘0’
uci commit
wifi restart

fi
fi

1 Like

If you do not need to disconnect repeater when usb is connected, you may just need to change priority of interfaces.

Change metric value in /etc/config/network and you do not need to do any script things.