System changes not being picked up

Hi,

I am trying to do a led change when a condition is met.
I use UCI to do the changes and then I commit and restart system service... but nothing happens.
On the other hand, if I do the same change in LuCI, the led change is applied.

The router is a TP-Link Archer C6(EU) v3.20
The wan LED has 2 possible options: 'green:wan' and 'amber:wan'
The version is OpenWrt 23.05.2, r23630-842932a63d

My piece of code is this

  wgstatus=$(ping -q -c "$count" -W "$timeout" "$ip" > /dev/null 2>&1 && echo "ok" || echo "fail")
  ledwgstatus=$(uci get system.led_wan.sysfs)

  if [ "${wgstatus}" = "ok" ]; then
    if [ "${ledwgstatus}" = "amber:wan" ]; then
      uci set system.led_wan.sysfs='green:wan'
      uci commit system
      service system restart   #service system reload   #/etc/init.d/system reload
  else
    if [ "${ledwgstatus}" = "green:wan" ]; then
      uci set system.led_wan.sysfs='amber:wan'
      uci commit system
      service system restart   #service system reload   #/etc/init.d/system reload
    fi
  fi

The statuses and uci set and uci get work as expected. What doesn't seem to be working is the uci commit system && service system restart I have also tried with service system reload and /etc/init.d/system reload.

logread -f does not show any traces when restarting the service.

root@archer-c6:~# /etc/init.d/system status
active with no instances

I don't know what "active with no instances" is. Is it relevant?

As an example:
If I do uci set system.led_wan.sysfs='amber:wan' the restart service won't do anything and my led will still be green.
If I restart reboot the change will be applied after the restart.
Another way to make it work is going to LuCI. In LuCI I can see my LED configuration changed to amber:wan. If I edit something silly like adding a letter to the name, and click "Save & Apply" the change will be applied successfully and the LED will turn amber.

What am I missing?

I have only seen the firewall (if something like rules for example are disabled) and network give any log entries with a restart. All other are just restarted.

The big question is really what the actual service for the led op are named, in OpenWrt the name of the config file is not necessarily the name of the service that use the specific part of a config file.

For example the dhcp config file is used by both the dnsmasq and odhcp services.

And system config file is at least used by system and ntp services.

Have you checked the wiki?

Active means that the service is "enabled" by having the symlink to init script in/etc/rc.d/
No instances means that the service does not leave a permanent daemon running (like most services).
Nothing special there.

But I think that you are handling the wrong init script / service.
LEDs have an own init script in /etc/init.d.
/etc/init.d/led restart might be the right for you.

2 Likes

There is a ”cheatsheet” for this. If I remember right it is the ucitrack config file that pretty much say what services that needs to be restarted for every config file.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.