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?