[Solved] Need help with writing a OpenWRT init script

EDITED:

I have a OpenWRT device that when I set one radio as a client, I want it to reverse back to (not a client) after a restart.
First I thought I could put something into my rc.local but the networking comes before rc.local, so that won’t work.

I was looking at the documentation

then

I would need to set something with a higher priority than networking.
something like uci set... to wipe the client config on boot

something like uci set wireless.@wifi-iface[2].default_disabled='1' && uci commit

Here Is what I have but it’s not working:

#!/bin/sh /etc/rc.common

START=20

boot() {
	uci set wireless.@wifi-iface[2].default_disabled='1' && uci commit
	}

I haven’t used openwrt or uci/luci in a while, but I would recommend adding some debug info- like write a timestamp when it runs, when it finishes, etc. it lets you see what is going on and/or what is going wrong. You might also be able to see the issue in the system logs.

It could be your script is running too early and the wifeless interface isn’t initialized, or maybe your script isn’t running at all.

And lastly, make sure you enabled your script.

I actually fixed it.

Its not iface[2] it’s [5]

#!/bin/sh /etc/rc.common

START=16
STOP=19

boot() {
       uci set wireless.@wifi-iface[5].default_disabled='1' && uci commit
       }

Works!

2 Likes