How to write scripts to change LEDs? (MT1300)

So I found this thread:

Where the guy wrote a custom script to get the LED to change when he was connected to a VPN. I have no idea how to do that.

I dont know anything about pulling stuff from bin and all that. How would I learn to change the LEDs and set custom LEDs?

On the Gl.inet firmware it always blinked blue when not connected and went solid white when it was connected to any AP as a client.

Now it just stays solid blue.

Any help would be appreciated.
Thanks!

Post return of ubus call system board

{
        "kernel": "5.10.161",
        "hostname": "OpenWrt",
        "system": "MediaTek MT7621 ver:1 eco:3",
        "model": "GL.iNet GL-MT1300",
        "board_name": "glinet,gl-mt1300",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "22.03.3",
                "revision": "r20028-43d71ad93e",
                "target": "ramips/mt7621",
                "description": "OpenWrt 22.03.3 r20028-43d71ad93e"
        }
}

Thanks!

You may want/need to learn.

"Pulling stuff from bin"?

Did you simply try asking @ray308 (:point_left: tagged them) yet?

Perhaps they will be willing to "teach" you.

Also FYI, you can edit LED behavior in the web GUI - but you likely won't get such advanced detail than the script posted in the other thread.

@Fastlane I wrote a solution on the forum for gl.inet. You may use that and pasted it in here if you want offcourse.

Please be aware that I probably broke a lot of things I’m apparantly not using, but it works for me.

1 Like

Nice! The man himself.

Im a complete newbie to this.
So Im using putty and navigated to /usr/bin
Theres no mt1300_led_deamon that even exists.

Im also using wireguard.
Note that if anyone is looking at this and uses wireguard instead, you’ll need to check for the existence of /sys/class/net/wg instead.*
It doesnt for me.

Dont know how to 'open' these files if they did exist?
Besides ./whatever.sh which I did here:

root@OpenWrt:~# /bin/sh


BusyBox v1.35.0 (2023-01-03 00:24:21 UTC) built-in shell (ash)

root@OpenWrt:~# . /usr/share/libubox/jshn.sh

Nothing happened.

Thanks for the help!

I'm not having the MT1300 around right now (it's at home, and I'm not)

I will look for you next weekend when I'm home. Maybe it's not there because of an other firmware version?

Remove the space.

not found

Can you show the whole input and output, please?

You need to create it.

ls /sys/class/net/wg

Makes little sense to me what you did.

Summary

This is based on @pavelgl code from Change GL-MT1300 led status on vpn connection that should work that way:

Ping works turn led to – solid white
Ping doesn’t work – blink blue

Copy the below code block and paste it in Putty

cat << "EOF" >  /usr/bin/mt1300_led_deamon
#!/bin/sh

ip="8.8.8.8"                    # Is google there?
count="1"                       # Ping Once
timeout="1"        
mt1300_led off                  # Initalize led to OFF
mt1300_led blue_breath daemon   # and then to normal blink blue startup

while true; do

status=$(ping -q -c "$count" -W "$timeout" "$ip"  > /dev/null 2>&1 && echo "ok" || echo "fail")

if [ "$status" = "ok" ]; then           # if google responds then   
		mt1300_led white daemon         # turn led on solid white
	else                                
		mt1300_led blue_breath daemon   # otherwise make sure it returns to blink blue   
	fi

sleep 10

done
EOF

Make it executable by issuing the below in Putty
chmod +x /usr/bin/mt1300_led_deamon

Restart the daemon by issuing the below in Putty
/etc/init.d/led restart

2 Likes