The button on an Opal and wireless activation

I consider I miss a button to activate, desactivate wireless. Is it possible to get this by the only button that is there and can be used for 3 functions allready...

Many years ago, the first function of the switch button is to turn on/off wifi.

But as no one uses it we changes.

1 Like

You can add a "WiFi" function to the Toggle switch options using one of the scripts HERE . Remember to add the file name to /etc/sysupgrade.conf if you want it to survive firmware upgrades.

3 Likes

Good news so, but I don't know how to install anything on a router. I am on Linux Mint though.

Under the covers the Opal runs OpenWRT, a Linux flavour focussed on networking kit with a nice, much simpler menu system added by GL.iNet. I'd suggest first installing the "nano" editor (Applications->Plugins on the Opal menus, easier to use than the default "vi" editor at the cost of some storage) and then, using the Terminal on your Linux Mint machine, ssh to the Opal's LAN interface address using your regular Opal admin password and add one of the linked scripts to the /etc/gl-switch.d directory plus the (full path) /etc/gl-switch.d/WiFi.sh file name within /etc/sysupgrade.conf . If this means nothing to you then you should probably leave well alone...!

At the point where I am, I don't even know my login name or username on Opal, only the password I added ...

Login name in luci and SSH is always root
Password is your password.

I think you may do better using the other, simpler script by @bring.fringe18 which is broadly similar to the version which works fine on my (dual radio WiFi5) Slate Plus. The WiFi adaptor names used in the @pforna script are different to those on my device and I guess may have changed with the later, AX devices? Run a uci show wireless command via ssh and check that the adaptor names shown there correspond to the values toggled in the script, and either edit the @pforna script to match your adaptors or use the simpler @bring.fringe18 script if that has matching names.
Also note that this script won't take account of any changes to the switch position when the router isn't powered and active, so don't toggle the physical switch when powered down. There are ways of determining the initial switch state, but that requires another script run on initialisation.

I don't really know what to do with this

root@GL-SFT1200:/etc/gl-switch.d# uci show wireless
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.txpower_max='20'
wireless.radio0.channel='auto'
wireless.radio0.band='2g'
wireless.radio0.hwmode='11g'
wireless.radio0.netisolate='0'
wireless.radio0.max_all_num_sta='64'
wireless.radio0.path='platform/11000000.wifi-lb'
wireless.radio0.htmode='HT40'
wireless.radio0.disabled='0'
wireless.radio0.country='US'
wireless.radio0.legacy_rates='0'
wireless.radio0.txpower='6'
wireless.default_radio0=wifi-iface
wireless.default_radio0.device='radio0'
wireless.default_radio0.network='lan'
wireless.default_radio0.mode='ap'
wireless.default_radio0.hidden='0'
wireless.default_radio0.ifname='wlan0'
wireless.default_radio0.wpa_group_rekey='36000'
wireless.default_radio0.isolate='0'
wireless.default_radio0.group='1'
wireless.default_radio0.disable_input='0'
wireless.default_radio0.wps_pushbutton='1'
wireless.default_radio0.wps_label='0'
wireless.default_radio0.encryption='psk2'
wireless.default_radio0.wds='1'
wireless.default_radio0.key='************'
wireless.default_radio0.ssid=****
wireless.default_radio0.disabled='1'
wireless.radio1=wifi-device
wireless.radio1.type='mac80211'
wireless.radio1.txpower='25'
wireless.radio1.txpower_max='25'
wireless.radio1.channel='auto'
wireless.radio1.band='5g'
wireless.radio1.hwmode='11a'
wireless.radio1.netisolate='0'
wireless.radio1.max_all_num_sta='64'
wireless.radio1.path='platform/17800000.wifi-hb'
wireless.radio1.htmode='VHT80'
wireless.radio1.disabled='0'
wireless.radio1.acs_noradar='1'
wireless.radio1.country='US'
wireless.radio1.legacy_rates='0'
wireless.radio1.channels='36,40,44,48'
wireless.default_radio1=wifi-iface
wireless.default_radio1.device='radio1'
wireless.default_radio1.network='lan'
wireless.default_radio1.mode='ap'
wireless.default_radio1.hidden='0'
wireless.default_radio1.ifname='wlan1'
wireless.default_radio1.wpa_group_rekey='36000'
wireless.default_radio1.isolate='0'
wireless.default_radio1.group='1'
wireless.default_radio1.disable_input='0'
wireless.default_radio1.wps_pushbutton='1'
wireless.default_radio1.wps_label='0'
wireless.default_radio1.ssid='GL-SFT1200-1fa-5G'
wireless.default_radio1.encryption='psk2'
wireless.default_radio1.wds='1'
wireless.default_radio1.key='************'
wireless.default_radio1.disabled='1'
wireless.guest2g=wifi-iface
wireless.guest2g.device='radio0'
wireless.guest2g.network='guest'
wireless.guest2g.mode='ap'
wireless.guest2g.ifname='wlan2'
wireless.guest2g.encryption='psk2'
wireless.guest2g.key='goodlife'
wireless.guest2g.ssid='GL-SFT1200-1fa-Guest'
wireless.guest2g.guest='1'
wireless.guest2g.disabled='1'
wireless.guest2g.wds='1'
wireless.guest2g.isolate='1'
wireless.guest5g=wifi-iface
wireless.guest5g.device='radio1'
wireless.guest5g.network='guest'
wireless.guest5g.mode='ap'
wireless.guest5g.ifname='wlan3'
wireless.guest5g.encryption='psk2'
wireless.guest5g.key='goodlife'
wireless.guest5g.ssid='GL-SFT1200-1fa-5G-Guest'
wireless.guest5g.guest='1'
wireless.guest5g.disabled='1'
wireless.guest5g.wds='1'
wireless.guest5g.isolate='1'

OK, the quick answer is that the @bring.fringe18 script should work but the @pforna script won't. The reason is that your (and my) WiFi radio names are "...radio0..." and "...radio1...", as referenced above in your uci show wireless output and in the earlier script, rather than "...wifi2g..." and "...wifi5g..." as referenced by the pforna script. Personally I'd simply replace the script you've added to the Opal with the bring.fringe18 version if you happy to control both 2.4GHz & 5GHz default interfaces in parallel. Also note that the script as posted won't change the state of the Guest interfaces (shown as disabled in your uci status). You should be able to figure out how to do this if you want to!

At first view, I don't understand why we couldn't replace wifi2g_default_disabled and wifi5g_default_disabled by wireless.default_radio0.disabled and wireless.default_radio1.disabled

No ?

Yes, should work, you only need to do this in the uci set ... commands although full replacement might be neater. Try it and see? If that doesn't work then you could always try the bring.fringe18 version...I'm a great believer in KISS - Keep It Simple, Stupid! - where possible!

OK, but I need a button to use only the 2.5 G with 5 G allways disabled... that's the deal. With my ISP's routeur, it was not possible to have only one of both activated.

If you want the switch to only change the state of the Main / Default 2.4GHz WiFi SSID then set the 5GHz Main SSID (and both Guest SSIDs) to your desired state (off) via the normal menu system and use the ultra-simple script HERE, which was the original version for my 2.4GHz-only Shadow.
Or,,, edit the script you've installed as you suggested!

This is my last post in this thread.

The script you've posted above has been truncated at 80 columns - I don't have time to figure out whether it's doing any damage to your Opal but if that's what you've been executing then I suggest you stop.

The script below will set the state of your 2.4GHz Main / Default SSID in line with a change to the switch position on your active router. Replace your current /etc/gl-switch.d/WiFi.sh with this script, or perhaps safer for you to give up the whole idea and use the regular menu system to control the WiFi status?
All the best...

#!/bin/sh

action=$1

if [ "$action" = "on" ];then
        uci set wireless.default_radio0.disabled='0'
        uci commit wireless
        wifi reload
        logger -p notice -t wifi-toggle "WiFi2g enabled"
fi

if [ "$action" = "off" ];then
        uci set wireless.default_radio0.disabled='1'
        uci commit wireless
        wifi reload
        logger -p notice -t wifi-toggle "WiFi2g disabled"
fi

sleep 5

I don't understand nothing to your allegations. Who truncated this script ? When ?

Of course it is what I ve executed and all is ok, it just doesn't work, very unexpectedly.

Notice than unlike on Linux Mint, Nano displays in a bad way when installed on GL... ctrl+A doesnt select all and it is difficult to copy paste the whole script I had to do it by pieces... but for me there was no difference between the script in wifi.sh and the copy I posted there.

In fact this solution is not really working because when we power down the router after having switched off the wireless by the button, at the power on, the wireless is still activated, and then we must switch two times to finally get the wireless be off.

so don't toggle the physical switch when powered down

If this "when" means "after powered down" this is not the problem, I didn't do that.

What does he mean by "full replacement" ?

NB : I see the truncated line in this pforna script but I think it is not truncated in the real script I tested, it is a problem coming from the Nano way on uci to display the content of the file I guess. It is not truncated when I use nano on Linux Mint.
I ll try again to see if it is working.

NB2 : I ve just deleted the post with the truncated script

You can make it work when power down as well.

Need another script to detect the switch position when powering on and that is it.

In fact I think I was wrong because now I can have it to work as expected, I have only not to touch the button when the device is powered down ... it is only logic not to do that. I must have forgotten to switch before powering down that's probaly why I ve had this wrong conclusion.
Everyday I power down the device at night and it works perfectly.

I only don't understand why the other script, was not working as expected. I guess it may be related to the fact that when wireless.default_radio0.disabled=0 is used to be written in /etc/wifi_default_status file , the content of this file is in reality .default_radio0.disabled=0 instead. (?)

Edit : this morning at startup I had again to switch 2 times to stop the wireless but I cannot be 100% sure that I didn't forget to switch it off yesterday before to power off. But it is likely what I made.