[openwrt/openwrt] base-files: allow forcing all LEDs to on/off/blink state
LEDE Commits
lede-commits at lists.infradead.org
Mon Dec 2 04:58:00 PST 2024
blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/1af15e8a2bf4d7ddd87d5f397064a5802eca5d67
commit 1af15e8a2bf4d7ddd87d5f397064a5802eca5d67
Author: John Crispin <john at phrozen.org>
AuthorDate: Fri Feb 9 18:10:12 2024 +0100
base-files: allow forcing all LEDs to on/off/blink state
* add a UCI option to disable all LEDs.
* add an init.d parameter to blink all LEDs
* add on/off parameters to init.d
Signed-off-by: John Crispin <john at phrozen.org>
---
package/base-files/files/etc/init.d/led | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index 7f05254c2b..377b9dcf3e 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -3,6 +3,10 @@
START=96
+extra_command "turnon" "Put the LEDs into their default state"
+extra_command "turnoff" "Turn all LEDs off"
+extra_command "blink" "Blink all LEDs"
+
led_color_set() {
local cfg="$1"
local sysfs="$2"
@@ -168,7 +172,31 @@ load_led() {
}
}
+turnoff() {
+ for led in `ls /sys/class/leds/`; do
+ echo 0 > /sys/class/leds/$led/brightness
+ done
+}
+
+turnon() {
+ turnoff
+ . /etc/diag.sh
+ set_state done
+ start
+}
+
+blink() {
+ for led in `ls /sys/class/leds/`; do
+ echo 0 > /sys/class/leds/$led/brightness
+ echo timer > /sys/class/leds/$led/trigger
+ done
+}
+
start() {
+ [ "$(uci -q get system. at system[-1].leds_off)" = '1' ] && {
+ turnoff
+ exit 0
+ }
[ -e /sys/class/leds/ ] && {
[ -s /var/run/led.state ] && {
local led trigger brightness color
More information about the lede-commits
mailing list