summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin2024-02-09 17:10:12 +0000
committerJohn Crispin2024-12-02 12:55:36 +0000
commit1af15e8a2bf4d7ddd87d5f397064a5802eca5d67 (patch)
treef9810faee3453e837d40c3c9252f8dfc419dc166
parent3b661cfcf9158a3dc5be6f7e1e1340339c9423b5 (diff)
downloadopenwrt-1af15e8a2bf4d7ddd87d5f397064a5802eca5d67.tar.gz
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@phrozen.org>
-rwxr-xr-xpackage/base-files/files/etc/init.d/led28
1 files changed, 28 insertions, 0 deletions
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.@system[-1].leds_off)" = '1' ] && {
+ turnoff
+ exit 0
+ }
[ -e /sys/class/leds/ ] && {
[ -s /var/run/led.state ] && {
local led trigger brightness color