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.

2 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!

I failed with this modified pforna script but now the content of the file /etc/wifi_default_status is .default_radio0.disabled .default_radio1.disabled
It differs with the requested content, no ?

I post the modified script I used

#!/bin/sh

# Default Settings
# File to save the wifi default status
wifi_default_status_file="/etc/wifi_default_status"

# If the wifi default status file is not (yet) available then use these default                                                                                                                                                              $
# 0 = enabled, 1 = disabled
wireless.default_radio0.disabled=0
wireless.default_radio1.disabled=0

action=$1

if [ "$action" = "off" ]; then

        # Get the default status before disabling
    wireless.default_radio0.disabled=$(uci get wireless.default_radio0.disabled)
    wireless.default_radio1.disabled=$(uci get wireless.default_radio1.disabled)

        # Save the default status to the wifi_default_status_file
        echo "$wireless.default_radio0.disabled $wireless.default_radio1.disabl                                                                                                                                                              $

        # if wifi2g is enabled then disable it
        if [ "$wireless.default_radio0.disabled" -eq 0 ]; then
        uci set wireless.default_radio0.disabled='1'
        uci commit wireless
        wifi reload
        logger -p notice -t wifi-toggle "wifi2g disabled"
    fi

        # if wifi5g is enabled then disable it
    if [ "$wireless.default_radio1.disabled" -eq 0 ]; then
        uci set wireless.default_radio1.disabled='1'
        uci commit wireless
        wifi reload
        logger -p notice -t wifi-toggle "wifi5g disabled"
    fi
fi

if [ "$action" = "on" ]; then

        # Check if the wifi_default_status_file is available
        if [ -f "$wifi_default_status_file" ]; then
                # If the file is available read the default status from the file
                read -r wireless.default_radio0.disabled wireless.default_radio                                                                                                                                                              $
        fi

        # if wifi2g is enabled by default then enable it
        if [ "$wireless.default_radio0.disabled" -eq 0 ]; then
        uci set wireless.default_radio0.disabled='0'
        uci commit wireless
        wifi reload
        logger -p notice -t wifi-toggle "wifi2g enabled"
    fi

        # if wifi5g is enabled by default then enable it
    if [ "$wireless.default_radio1.disabled" -eq 0 ]; then
        uci set wireless.default_radio1.disabled='0'
        uci commit wireless
        wifi reload
        logger -p notice -t wifi-toggle "wifi5g enabled"
    fi
fi

sleep 5



So I checked the log also, and when the button is pressed I get well user.notice gl-switch: switch pressed
but never wifi2g disabled or wifi5g disabled etc

Is this normal ? I guess that no, but I don't really understand what this "wireless default status" is really, it is the state of the GUI interface at wireless on off etc ? but then it would be called "current" non ? "current status"

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.

The script you proposed to use, is working though
Can we add something to do that the light reflects the wireless status ?

1 Like